I\'m trying to loop through a hash table and set the value of each key to 5 and PowerShell gives an error:
$myHash = @{} $myHash[\"a\"] = 1 $myHash[\"b\"] =
Use clone:
clone
foreach($key in ($myHash.clone()).keys){ $myHash[$key] = 5 }
Or in the one-liner:
$myHash = ($myHash.clone()).keys | % {} {$myHash[$_] = 5} {$myHash}