title: Foreach loop in powershell with hasharray
body: <p>I'm writing a powershell script to ping all the servers and check which are offline. but i have a bug. By name it works perfectly. But when i do test-connection with an IP it seems to work BUT i cant output the name of the IP in the hashlist. Could someone help me figure this out? Thanks!!</p>
  <p>System.Collections.Hashtable.keys Is online/available, This is what it outputs. But i want it to say &quot;Servername is online/available&quot;</p>
  <pre><code>#Creating IP Array list
  $ip_array = @{
  Server = [ipaddress] &quot;192.168.1.1&quot;
  sws = [ipaddress] &quot;192.168.1.1&quot;
  }
  
  
  
  Foreach ($ip in $ip_array)
  {   
      if((Test-Connection -IPAddress $ip.values.ipaddresstostring -quiet -count 1 ) -eq $false)
      {
          
          write-output(&quot;$ip.keys  Is offline/unavailable, please troubleshoot connection, script is terminating&quot;)  | Red 
      }
      else
      {
          $ping = $true
          write-output(&quot;$ip.keys Is online/available&quot;) | Green
      }
  }
  </code></pre>