Changes

Jump to: navigation, search

Windows PowerShell 1.0 Hashtables

907 bytes added, 20:03, 19 November 2008
Clearing All Elements from a Windows PowerShell Hashtable
PS C:\Users\Administrator> $book.Count
0
</pre>
 
== Combining Hashtables ==
 
Elements in two or more hashtables may be combined using a variety of techniques. One important point to note is that the combination can only be performed by PowerShell if there are no duplicated keys in the hashtables. If duplicate keys are found the operation will fail.
 
The elements in one hashtable may be added those in another hashtable using the += operator. In the following example, the elements in ''$book2'' are added to ''$book1'':
 
<pre>
PS C:\Users\Administrator> $book1 += $book2
</pre>
 
Alternatively, a new hashtable may be created comprised of the elements in multiple other hashtables using the + operator. For example, the following command creates a new hashtable named ''$book4'' which contains copies of all the elements in the ''$book1'', ''$book2'' and ''$book3'' hashtables:
 
<pre>
PS C:\Users\Administrator> $book4 = $book1 + $book2 + $book3
</pre>

Navigation menu