PowerShell Performance: Avoiding the pipeline part 1

The PowerShell pipeline is a practial tool in the shell. But if you are writing scripts or workflows, avoid the pipeline! It will increase the running time of your script/workflow.

Run to following script on your machine to see the difference:

On my machine, the operation with the foreach-object (pipeline) took 4.7s longer than a simple foreach.

Another advantage is the readability of your code: while using the pipeline, the name of the control variable is given ($_), you can choose a meaningful name in a simple foreach (e.g. foreach ($process in Get-Process)).