A dictionary can return the information it holds in several ways. Start with this dictionary:
$dictionary = New-Object System.Collections.Generic.Dictionary"[String,IPAddress]" $dictionary.Add("Computer1", "192.168.10.222") $dictionary.Add("Computer2", "192.168.10.13")
Keys can be returned using the Keys property of the dictionary, which returns a KeyCollection:
$dictionary.Keys
Values can be returned using the Values property, which returns a ValueCollection. The key is discarded when using the Values property:
$dictionary.Values
A simple loop can be used to retain the association between key and value:
foreach ($key in $dictionary.Keys) { Write-Host "Key: $key Value: $($dictionary[$key])" }