title: Unable to index into an array to turn it into a hash table
body: <p>I am trying to convert an array into a hashtable but I keep getting this error</p>
  
  <p>Unable to index into an object of type System.Management.Automation.PSObject.</p>
  
  <p>I have searched everywhere and could not find others having the same problem.</p>
  
  <p>My code:</p>
  
  <pre><code>[array]$compArray = $ds3 | select -Property DeviceName, IP_Address
  
  $DeviceHashtable = @{}
  $compArray[0][0]
  for ($i=0;$i -lt $compArray.length;$i++)
      {
      $1=[string]$compArray[0][$i];
      $2=[string]$compArray[1][$i];
      $DeviceHashTable.add("$1", "$2")
      }
  </code></pre>
  
  <p>$ds3 is a system.data.datatable object
  and if I do $compArray | display-table all the data I want is there.
  Any help is  appreciated :)</p>