Skip to content

Latest commit

 

History

History

Unrolled-collections

Unrolled collections

PowerShell may unroll collections, that is replace an original collection with an array of its items or just a single item.

This fact is especially easy to forget for some complex objects like [System.Data.DataTable]. PowerShell may treat it as a collection of [System.Data.DataRow] and the original table instance may be "lost".

The common workaround is use of the comma operator which wraps an argument with an array of a single item. This array is unrolled and this gets its single item as it is, not unrolled.

Scripts