Difference between where-object and select-object
Understand the difference between where-object and select-object
John Savill
February 9, 2017
1 Min Read
Q. What is the difference between where-object and select-object?
A. The two cmdlets perform very different things.
Where-object restricts which objects are returned, for example:
Get-Process | Where-Object {$_.Name -eq "WmiPrvSE"}
Will only return objects whose name is WmiPrvSE.
Now compare to Select-Object, e.g.
Get-Process | Select-Object -Property Name, ID
Returns the name and process ID for every process. You could put these together:
Get-Process | Where-Object {$_.Name -eq "WmiPrvSE"} | Select-Object -Property Name, ID
To return only the Name and ID for the WmiPrvSE process instances.
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like