Powershell: Filter Hashtable – and get back a Hastable

Question:

Filtering a Hashtable using GetEnumerator always returns a object[] instead of a Hashtable:

Is there a nice solution to this problem?

Thanks a lot for any Help!,
kind regards,
Tom

Answer:

$filtered is an array of dictionary entries. There’s no single cast or ctor for this as far as I know.

You can construct a hash though:

Another workflow:

Source:

Powershell: Filter Hashtable – and get back a Hastable by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply