title: Reading values from CSV files and storing in local variable in PowerShell
body: <p>I am stuck at one point, the requirement is I have to store the Username, Password, Hostname &amp; hostkey in a CSV file and I have to read &amp; store the values in local variable which can be used for establishing SFTP connection.</p>
  
  <p>My CSV looks like this:</p>
  
  <pre>
  HostName,Username,Password,SshHostKeyFingerprint
  abc.com,Lear,qwert,ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx...
  </pre>
  
  <p>The code which I am using to read and store the different columns values is:</p>
  
  <pre><code>Add-Type -Path "WinSCPnet.dll"
  
  $csv = Import-Csv c:\test\output.csv
  $csv | ForEach-Object
  {
      $Hostname = $_.hostname
      $username = $_.username
      $Password = $_.Password
      "$Hostname - $username -$Password"
  }
  
  # Set up session options
  $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
      Protocol = [WinSCP.Protocol]::Sftp
      HostName = $Hostname
      UserName = $username
      Password = $Password
      SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
  }
  </code></pre>
  
  <p>Nothing is getting displayed, when trying to display the values.</p>