Are you confused and unable to know whether you should use the Where-Object or the Select-Object in PowerShell? In this PowerShell tutorial, I will explain the differences between PowerShell where-object vs. select-object and when you should use which one.
What is Where-Object in PowerShell?
The Where-Object cmdlet in PowerShell is used to filter objects based on their property values. It allows you to pass through objects that meet certain criteria and exclude those that do not. Essentially, Where-Object is a filtering tool.
For example, if you want to find processes that are consuming more than 50MB of memory, you could use Where-Object like this:
Get-Process | Where-Object { $_.WS -gt 50MB }In this command, Get-Process retrieves all processes, and Where-Object filters these processes based on the condition provided in the script block { $_.WS -gt 50MB }, where $_ represents each object (process) in the pipeline, .WS refers to the working set (memory usage), and -gt is the operator for ‘greater than’.
What is Select-Object in PowerShell?
On the other hand, Select-Object is used to select specific properties of an object or a set of objects. It can also be used to create new calculated properties or to select a unique or specific number of objects from a collection.
For instance, if you want to display only the name and ID of all processes, you could use Select-Object like this:
Get-Process | Select-Object Name, IdThis command will output a table with just the Name and Id properties of each process.
Examples of Where-Object and Select-Object in Use
Let’s consider a real-world scenario where you might need to use both Where-Object and Select-Object in PowerShell. Suppose you need to retrieve a list of currently running services and display their name and status. Here’s how you could do this by using the below PowerShell script.
Get-Service | Where-Object { $_.Status -eq 'Running' } | Select-Object Name, StatusIn this pipeline, Get-Service retrieves all services, Where-Object filters only the services that are running, and Select-Object selects the Name and Status properties to be displayed.
Check out How to Change Directory in PowerShell?
Differences Between PowerShell Where-Object and Select-Object
Now, let’s summarize the differences between these two cmdlets: PowerShell Where-Object and Select-Object.

| Feature | Where-Object | Select-Object |
|---|---|---|
| Purpose | Filters objects based on property values | Selects specific properties of objects |
| Usage | To include/exclude objects in the pipeline | To manipulate or display object properties |
| Example | Get-Process | Where-Object { $_.CPU -gt 10 } | Get-Process | Select-Object Name, CPU |
| Output | Objects that meet the criteria | Objects with only the selected properties |
| Flexibility | Used for comparison operations | Used for property selection and manipulation |
Conclusion
Where-Object and Select-Object are two distinct cmdlets in PowerShell with different purposes. Where-Object is a filter that allows you to specify conditions to include or exclude objects in the pipeline, whereas Select-Object is used to select specific properties from objects or to create new calculated properties.
I hope now you know the differences between PowerShell Where-Object and Select-Object cmdlets and you know where to use Where-Object and where to use the Select-Object in PowerShell.
You may also like:
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.