PowerShell Access a hash table value by key.


Example

An example of defining a hash table and accessing a value by the key

$hashTable = @{
    Key1 = 'Value1'
    Key2 = 'Value2'
}
$hashTable.Key1
#output
Value1

An example of accessing a key with invalid characters for a property name:

$hashTable = @{
    'Key 1' = 'Value3'
    Key2 = 'Value4'
}
$hashTable.'Key 1'
#Output
Value3