Does powershell have associative arrays? Does powershell have associative arrays? arrays arrays

Does powershell have associative arrays?


also

$a = @{'foo'='bar'}

or

$a = @{}$a.foo = 'bar'


Yes. Use the following syntax to create them

$a = @{}$a["foo"] = "bar"


Will add also the way to iterate through hashtable, as I was looking for the solution and did not found one...

$c = @{"1"="one";"2"="two"} foreach($g in $c.Keys){write-host $c[$g]} #where key = $g and value = $c[$g]