Remove Keys From a Hash Table

by May 30, 2011

Once you create a hash table, it is easy for you to add new key-value pairs like this:

PS > $myHash = @{}
PS > $myHash.Name = 'Tobias'
PS > $myHash.ID = 12
PS > $myHash.Location = 'Hannover'
PS > $myHash

Name                           Value
----                           -----
ID                             12
Name                           Tobias
Location                       Hannover

Use its Remove() method to remove a key from a hash table:

PS > $myHash.Remove('Location')
PS > $myHash

Name                           Value
----                           -----
ID                             12
Name                           Tobias

 

Twitter This Tip!
ReTweet this Tip!