Delete value from hashtable in powershell

Question:

I want to delete a specific value from hashtable.

The table looks like this:

How can I delete the “test2” value?

I tried the following:

$myhashtable.remove(“test2”)

which unfortunately does not work.

Could someone help me with this? Thanks!

Answer:

The example that you provided looks like a hashtable of hashtables. So you would need to do:

If it is a hashtable where the value is an array, then you would need to do this:

Source:

Delete value from hashtable in powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply