October 9th, 2014

PowerTip: Empty Hash Table with PowerShell

Doctor Scripto
Scripter

Summary: Learn how to easily empty a hash table by using Windows PowerShell.

Hey, Scripting Guy! Question I want to write new values to a hash table, and I want to ensure that it contains none of the original keys or values.
           How can I accomplish this task without deleting and re-creating the hash table?

Hey, Scripting Guy! Answer Use the Clear method from the hash table object, for example:

PS C:\> $a = @{a=1;b=2;c=3} 

PS C:\> $a.Clear()

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback