Chapter 10. Avoiding the pipeline

Jeff Wouters

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 ...

Get PowerShell Deep Dives now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.