0

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
}
4

1 回答 1

2

Replace:

$dict.Keys | ForEach-Object {
    Write-Host $_hostname
}

with:

$dict.Keys | ForEach-Object {
    Write-Host $dict[$_]
}
于 2013-10-01T09:32:46.793 回答