Foreach-Object with HashTables?

Question:

I’m trying to check wheter some network drives are mapped via logon script. If they’re not mapped, the script should be able to map them but My Foreach-Object in the code below doesn’t work. why? Can’t I use it on hashtables?

How do I have to use foreach in this situation? Or is there a better way to solve this issue instead of a hashtable or a foreach loop?

Answer:

To iterate over a [hashtable] you need to get an enumerator for it:

Source:

Foreach-Object with HashTables? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply