September 2006
Intermediate to advanced
115 pages
2h 19m
English
PowerShell hashtables (also called associative arrays) allow you to associate keys with values. To define a hashtable, use the syntax:
$myHashtable = @{}You can initialize a hashtable with its key/value pairs when you create it. PowerShell assumes that the keys are strings, but the values may be any datatype.
$myHashtable = @{ Key1 = "Value1"; "Key 2" = 1,2,3 }To access or modify a specific element in an associative array, you may use either the array-access or property-access syntax:
$myHashtable["Key1"]
Returns "Value1".
$myHashtable."Key 2"
Returns the array 1,2,3.
$myHashtable["New Item"] =
5
Adds "New Item" to the
hashtable.
Read now
Unlock full access