A hashtable can return the information it holds in several ways. Start with hashtable:
$hashtable = @{ Key1 = 'Value1' Key2 = 'Value2' }
Keys can be returned using the Keys property of the hashtable, which returns a KeyCollection:
$hashtable.Keys
Values can be returned using the Values property, which returns a ValueCollection. The key is discarded when using the Values property:
$hashtable.Values
A simple loop can be used to retain the association between the key and value:
foreach ($key in $hashtable.Keys) { Write-Host "Key: $key Value: $($hashtable[$key])" }