As a PowerShell developer, you should know how to use the PowerShell Select-Object cmdlet. In this tutorial, I will explain the cmdlet’s syntax and provide a few examples.
The Select-Object cmdlet in PowerShell allows you to filter and select specific properties from objects. For example, if you want to display only the process name and ID from a list of running processes, you can use the command Get-Process | Select-Object -Property Name, Id. This will output the list containing just the Name and Id properties, helping you focus on the essential information.
What is Select-Object in PowerShell?
The Select-Object PowerShell cmdlet allows you to select specific properties from objects or create new properties. This is particularly useful when you need to filter out unnecessary data and focus on the information that matters most.
Syntax of PowerShell Select-Object
Here is the basic syntax for Select-Object:
Select-Object [-Property] <Object[]> [-ExcludeProperty <String[]>] [-ExpandProperty <String>] [-Unique] [-InputObject <PSObject>] [-First <Int32>] [-Last <Int32>] [<CommonParameters>]Below are some of the key parameters:
- -Property: Specifies the properties to select.
- -ExcludeProperty: Excludes specified properties from the output.
- -ExpandProperty: Expands a property that is an object or array.
- -Unique: Ensures that only unique objects are selected.
- -First: Selects the first specified number of objects.
- -Last: Selects the last specified number of objects.
Also, check out PowerShell Copy-Item
PowerShell Select-Object Examples
Now, let me show you a few examples of using the Select-Object PowerShell cmdlet. You will learn how to use this cmdlet.
1. Select Specific Properties
Suppose you have a list of services running on your system, and you want to display only the service name and status. You can achieve this with Select-Object. Below is the PowerShell script.
Get-Service | Select-Object -Property Name, StatusThis command will output a list of services with just the Name and Status properties.
You can see the exact output in the screenshot below:

2. Rename Properties
You might want to rename properties for better readability. For example, let’s say you want to rename Name to ServiceName. You can do this by using the below script:
Get-Service | Select-Object -Property @{Name='ServiceName';Expression={$_.Name}}, StatusHere, we use a hash table to specify the new name and the expression to extract the original property.
Check out PowerShell Write-Output
3. Select Unique Objects
If you have a collection of network adapters and you want to display only unique adapter names, you can use the -Unique parameter of Select-Object PowerShell cmdlet. Consider a scenario where you have a list of network adapters:
Get-NetAdapter | Select-Object -Property Name -UniqueThis command will ensure that only unique adapter names are displayed.
4. Select the First or Last N Objects
Sometimes, you might be interested in only the first or last few objects from a collection. You can use the Select-Object cmdlet to get the first or last N objects.
For instance, to get the first 3 services:
Get-Service | Select-Object -First 3Here is the exact output in the screenshot below:

Or to get the last 3 services:
Get-Service | Select-Object -Last 3Check out PowerShell Write-Host vs Out-Host
5. Expand Properties
When dealing with nested objects, you might need to expand a property to access its contents. For example, if you have a property that contains an array of IP configurations:
Get-NetIPAddress | Select-Object -ExpandProperty IPAddressThis command will expand the IPAddress property, displaying the details of each IP address configuration.
6. Create Custom Objects
You can also use the PowerShell Select-Object to create custom objects with calculated properties. For example, let’s create a custom object that includes the service name, status, and a calculated property for start type:
Get-Service | Select-Object -Property Name, Status, @{Name='StartType';Expression={$_.StartType}}This command adds a new property StartType to the output.
Here is the exact output in the screenshot below:

Read Create Custom Objects in PowerShell
7. Filter Data Based on Conditions
You can combine Select-Object with other cmdlets, like Where-Object to filter data based on specific conditions in PowerShell. For example, to list services that are currently running; here is the script.
Get-Service | Where-Object {$_.Status -eq 'Running'} | Select-Object -Property Name, StatusThis command filters services based on their status and then selects the relevant properties.
I executed the above PowerShell script using VS code, and you can see the exact output in the screenshot below:

Check out PowerShell Select-Object Without Header
PowerShell select-object order by
The Select-Object cmdlet in PowerShell is often used in combination with the Sort-Object cmdlet to order the results based on specific properties. Here’s a practical example to understand how you can use Select-Object and Sort-Object together.
Example: Order Services by Status
Suppose you want to list services on your system and order them by their status (Running, Stopped, etc.) and then select only the service name and status properties.
Here’s how you can achieve this:
Get-Service | Sort-Object -Property Status | Select-Object -Property Name, StatusExplanation:
- Get-Service: This cmdlet retrieves all the services on the system.
- Sort-Object -Property Status: This sorts the services by their
Statusproperty. By default, sorting is done in ascending order. - Select-Object -Property Name, Status: This selects only the
NameandStatusproperties from the sorted list of services.
Output:
The command will output a list of services ordered by their status, showing only the Name and Status properties. For example, in the output below screenshot, you can see that the services are ordered by their status, with all stopped services listed first, followed by running services.

Check out PowerShell Select-Object -Unique
PowerShell select-object expression Examples
One of the powerful features of Select-Object is the ability to use expressions to create calculated properties. This is particularly useful when you need to manipulate data on the fly.
Suppose you have a list of employees, and you want to create a custom property that combines their first and last names into a full name. Here’s how you can achieve that:
$employees = @(
[PSCustomObject]@{FirstName="John"; LastName="Doe"; JobTitle="Manager"},
[PSCustomObject]@{FirstName="Jane"; LastName="Smith"; JobTitle="Developer"},
[PSCustomObject]@{FirstName="Emily"; LastName="Johnson"; JobTitle="Designer"}
)
$selectedEmployees = $employees | Select-Object FirstName, LastName, JobTitle, @{Name="FullName"; Expression={$_.FirstName + " " + $_.LastName}}
$selectedEmployeesExplanation
- Input Data: A list of employees with properties
FirstName,LastName, andJobTitle. - Select-Object: We use
Select-Objectto select the existing properties and create a new property calledFullName. - Expression: The
Expressionkey in the hash table concatenatesFirstNameandLastName.
When you execute the PowerShell script, you can see the exact output in the screenshot below.

Also, check out PowerShell Select-Object -First
PowerShell Select-Object Filter
Now, let me explain how to use the filter in PowerShell Select-Object with Where-Object and provide a few useful examples.
You can combine Select-Object and Where-Object to create various filters. For example, let’s find all services that are running and select their DisplayName and Status:
Get-Service | Where-Object { $_.Status -eq 'Running' } | Select-Object DisplayName, StatusThis command first filters the services that are running and then selects only the DisplayName and Status properties.
Here is the exact output you can see in the screenshot below:

Conclusion
The Select-Object cmdlet in PowerShell allows you to manipulate and filter data efficiently. In this tutorial, I explained how to use the PowerShell Select-Object cmdlet with a few examples like renaming properties, selecting unique objects, or creating custom calculated properties, etc.
I hope this guide has given you a complete understanding of how to use Select-Object in PowerShell.
Note: For execution of all the above PowerShell scripts, I used Visual Studio Code; you can use any other preferred editors.
You may also like:
- PowerShell Write-Host
- PowerShell Prompt for Input Yes/No
- PowerShell Sort-Object
- PowerShell Select-Object Value Only
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.