Using Hash Tables

by Nov 12, 2008

Hash Tables are a great way to organize data. A hash table stores key-value-pairs. To create a new hash table variable, try this:

$person = @{}

You can then add new key-value-pairs by simply using the dot notation:

$person.Age = 23
$person.Name = 'Tobias'
$person.Status = 'Online'
$person.Name
$person

Optionally, you can use a Hash Table like a field and access its keys in square brackets:

$person['Age']

You can even use other variables to access its keys:

$info = 'Age'
$person.$info