Author Posts

May 16, 2017 at 5:28 pm

Hi, I'm giving a PowerShell class and one of the students asked a question related to the modes of processing data within a powershell pipeline (streaming vs. sequential mode)

Given a typical pipeline like:

Get-ChildItem | Sort-Object Length | Select-Object Length, Name | ForEach { ... }

Will Sort-Object switch the entire pipeline to sequential processing meaning that all pipeline commands are executed one at a time

... or ...

Will only Sort-Object hand over its entire (sorted) results to the next command while the rest of the pipeline remains in streaming mode or rather real-time processing.

Thanks

May 16, 2017 at 5:55 pm

There's no way to "switch" the pipeline. Sort merely declines to emit anything until it's gotten the all-clear that nothing more is coming. It then emits its results on object at a time, and they continue to stream down the pipeline in that fashion unless someone else "blocks."

There is no "mode" for the pipeline.