Filter left narrows results as close to the retrieving cmdlet as possible. The cmdlet returns only matching objects, reducing unnecessary work for later pipeline commands and possibly limiting information transmitted across a network. section 12.1 section 12.2
Select process names immediately
Get-Process -Name p*,*s* asks Get-Process to retrieve only process names matching the supplied patterns. This is preferable to retrieving every process and filtering afterward when the cmdlet supports the needed criteria. section 12.1
Use filter left with these practical limits in mind:
- Check the retrieving cmdlet's parameters because each cmdlet implements filtering differently; Get-Process, for example, filters by Name or Id. section 12.2
- Use Where-Object when the first cmdlet cannot express the required condition; it filters retrieved objects in the pipeline using comparison operators. section 12.2
- Keep Where-Object as early in the pipeline as possible when it is necessary, even though filtering in the retrieving cmdlet is better. section 12.5
Get-Process -Name p*,*s*
Explore a direct Get-Process filter using wildcard name patterns. section 12.1
