PowerTip: Empty Hash Table with PowerShell


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()

Comments (1)

Skip to main content