Add a key value pair to an existing hash table

suggest change

An example, to add a “Key2” key with a value of “Value2” to the hash table, using the addition operator:

$hashTable = @{
    Key1 = 'Value1'
}
$hashTable += @{Key2 = 'Value2'}
$hashTable

#Output

Name                           Value
----                           -----
Key1                           Value1
Key2                           Value2

An example, to add a “Key2” key with a value of “Value2” to the hash table using the Add method:

$hashTable = @{
    Key1 = 'Value1'
}
$hashTable.Add("Key2", "Value2")
$hashTable

#Output

Name                           Value
----                           -----
Key1                           Value1
Key2                           Value2

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents