Working concept of pipeline

suggest change

Pipeline commands do not run as parallel threads. They run in one process, and objects move one at a time. A cmdlet with a process block can pass an object downstream before it receives the next one. That streaming is why output can start before the whole input is finished. It is not a speedup from multiple threads. A foreach statement that first collects every object, then loops, waits longer to start the later steps.

@( bigFile_1, bigFile_2, ..., bigFile_n) | Copy-File | Encrypt-File | Get-Md5
  1. Copy-File copies the first file and passes it on.
  2. Copy-File copies the second file while Encrypt-File encrypts the first.
  3. Copy-File copies the third file while Encrypt-File encrypts the second and Get-Md5 hashes the first.

"While" here means interleaved on one thread, not three threads at the same time. ForEach-Object -Parallel (PowerShell 7) is a separate feature and is not what | does.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents