$someHashTable = @{} $someHashTable.Add("key1", "value1") $someHashTable.Add("key2", "value2") $someHashTable.Keys | %{ $someHashTable[$_] = "newValue" }
It should looks like below code - collection of keys must be copied to fresh new collection.
$someHashTable = @{} $someHashTable.Add("key1", "value1") $someHashTable.Add("key2", "value2") $keys = @(); $someHashTable.Keys | %{ $keys += $_ } $keys | %{ $someHashTable[$_] = "newValue" }