What is Hash Table in PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

Hash table in a PowerShell is constructed with the Key-Value combination. Each key has its own value, so to get the value we need to refer the Key. We don’t need numeric indexing like Array to refer values.

This is how the hash table looks like.

Name        Value
----        -----
EmpName     Charlie
City        New York
EmpID       001

In the hash table creation, keys and values are separated with Semi-colons (;). In the above example, EmpName, City and EmpID are referred as keys while Charlie, New York and 001 are their values respectively.

Hash table is the OrderedDictionary, if you check the hash table type, it would be collection of values (System.Object).

IsPublic       IsSerial       Name                   BaseType
--------       --------       ----                   --------
True           True           OrderedDictionary      System.Object
Published on 26-Feb-2020 14:34:38