Creating hash table with more than two columns
hello,
tried search around , can't quite find i'm trying do. know can make hash table like:
$hash = @{"texas" = "hot";"alaska" = "cold"}
but add third column, sake of example have third 1 travel air , other travel car. what's syntax can add more columns two? also, how can change column header names?
i think want more this:
new-object psobject -property @{ state="texas" temp="hot" travel="air" }
if set $hash equal that:
$hash = new-object psobject -property @{state="texas";temp="hot";travel="air"}
i this:
travel temp state
------ ---- -----
air hot texas
if have master variable
$hashes = @()
i can set $hash new-object of relevant values each pass of loop:
$hash = new-object psobject -property @{state="alaska";temp="cold";travel="car"}
and add $hashes each time:
$hashes += $hash
and add collection:
travel temp state------ ---- -----
air hot texas
car cold alaska
as mjolinor suggested, need understand want do. i suspect unfamiliar terms, because you're describing array of values, better suited psobject rather hash table.
the method populating psobject describe above 1 variation of 1 particular method doing so, there others may more or less suitable want do.
i hope post has helped!
Windows Server > Windows PowerShell
Comments
Post a Comment