This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

PowerShell Quicktip #2: Filter-Left

A practical example of why you should filter as far left in your scripts as possible. It might matter.

Get-Service | Where-object { $_.Status -eq 'Running' -and $_.name -like 's*'}
Get-Service -name s*| Where-object { $_.Status -eq 'Running'}

Measure-Command -Expression {Get-Service | Where-object { $_.Status -eq 'Running' -and $_.name -like 's*'}}
Measure-Command -Expression {Get-Service -name s*| Where-object { $_.Status -eq 'Running'}}


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.