Indexing into a PowerShell value collection

Question:

Given:

I get the output:

Why does the first element have both values and the second have none? How do I get the values as a collection I can index?

Answer:

I figured it out. The solution is to convert the Values ICollection to an array of strings.

With:

The output becomes as originally expected:

I cannot help but feel that this should be the default behaviour.

Source:

Indexing into a PowerShell value collection by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply