Monday, December 30, 2019

Putting an array on the pipeline with the unary comma operator

When output onto the pipeline, PowerShell arrays tend to explode into individual pipeline items. I used to deal with this by passing arrays as parameters instead. Recently, though, I heard about the unary comma operator. Placing a single comma before any value, including an array, produces a single-element array containing the value. When that explodes onto the pipeline, it releases the original array.

No comments:

Post a Comment