Reputation: 13206
How would I go about reading all the key values in a hash table? I'm currently trying the below and it returns nothing.
$dict = @{}
Import-CSV hostname.csv | ForEach-Object {
if ($dict.Keys -contains $_.type) {
$dict[$_.type]+=$_.hostname
} else {
$dict[$_.type] = @($_.hostname)
}
}
$dict.Keys | ForEach-Object {
Write-Host $_hostname
}
Upvotes: 0
Views: 2203
Reputation: 3784
Replace:
$dict.Keys | ForEach-Object {
Write-Host $_hostname
}
with:
$dict.Keys | ForEach-Object {
Write-Host $dict[$_]
}
Upvotes: 2