Hash table in PowerShell
hashtable is easy to create, access and manipulate.
we simply use
$hashTable = @{}
to create an empty hash table.
and use
$hashTable.color = "Blue"
to set the key and value pair.
refer to http://ss64.com/ps/syntax-hash-tables.html, it is very flexible to use hash table.
one thing I want to point out is that whenver we want to traverse the hashtable, what can we do ?
just like an Array in PowerShell, using ForEach can do it.
For hashtable, we can use like:
foreach ($dog in $dogs.GetEnumerator()) { # do what you like }
or
$hashtable.GetEnumerator() | ForEach-Object { … }