PowerShell/GetEnumerator

Question:

I have a simple question:

Why the program below does not write the whole array $lines? It is looping forever. I am really confused..

Answer:

It seems as though the expression:

unwinds the entire enumerator. For e.g.:

So, when you try to pass your expression to the function, it is rendered invalid. The only workaround I can think of is to pass it as a PSObject like so:

Source:

PowerShell/GetEnumerator by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply