Imagine you have a Hashtable such as this:
$ht = @{
Foo = @{
Bar = "Baz"
Qux = "Quux"
}
Quuz = @{
Bar = "Corge"
Qux = "Grault"
}
}
Imagine that you want to get an array of each of the Hashtable's Bar property. How would you go about this? Is this possible without iterating?
This is what I came up with:
$arr = @()
foreach ($i in $ht.GetEnumerator()) {
foreach ($n in $i.Name) {
$arr += $ht.$n.Bar
}
}
PS C:> echo $arr
Corge
Baz
Really, though, it seems to me it should be simpler. Perhaps using PSCustomObject & Select-Object? I'm open to any solutions.