Chapter 10. Avoiding the pipeline
Whether you’re new to PowerShell or you’re at a more advanced level, I encourage you to always consider performance and execution time when you write a script.
One of the most powerful features of PowerShell is its ability to use the pipeline. Finding objects, filtering them to return the ones you want, and performing an action on those objects is easy to do with pipelined expressions, which I refer to as the pipeline. Every step is one pipe in the pipeline. In general, the fewer pipes you use, the shorter the execution time and the fewer resources that are used.
Although creating one-liners is easy to learn and understand, following best practices yields the best performance. If you don’t implement ...