October 22nd, 2014

PowerTip: Use PowerShell 4.0 Where Operator to Filter

Doctor Scripto
Scripter

Summary: Use Windows PowerShell 4.0 Where operator to filter results.

Hey, Scripting Guy! Question How can I use a Where operator in Windows PowerShell (without using the pipeline or Where-Object)
           to filter through processes?

Hey, Scripting Guy! Answer Use Get-Process  to group the processes into a collection, then use the Where operator
           and filter on the process name, for example:

(Get-process).Where({$_.ProcessName -eq 'winlogon'})

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback