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:
1 2 3 4 5 6 7 8 9 10 11 |
Measure-Command { 1..1000000 | ForEach-Object { $i = $_ * $_ } } Measure-Command { foreach($number in 1..1000000) { $i = $number * $number } } |
On my machine, the operation with the foreach-object (pipeline) took 4.7s longer than […]