How it works...
What we just created was an associative array, also known as a hashtable. These are arrays with named elements. Instead of accessing the values using an index, we use a name.
In this recipe, we associate the process name to the working set of each of the processes running in the system.
The first step is to initialize a hashtable. An array is initialized using @(), whereas a hashtable is initialized using @{}. The next step is to add data as we would to an array. However, when adding content to an array, we simply add the values. In the case of hashtables, though, each value must be accompanied by a name. Therefore, we use the $Variable['Name'] = Value format.
In this recipe, we add content to the hashtable using a Foreach-Object ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access