Select-Object is a PowerShell CmdLet that selects or shapes the properties of objects coming through the pipeline. It is commonly used to limit output, pick specific properties, or create new calculated properties.

Basic usage

Select only specific properties:

Get-Process | Select-Object Name, Id, CPU

Select the first or last N objects:

Get-Process | Select-Object -First 5
Get-Process | Select-Object -Last 3

Expand a single property

-ExpandProperty returns the raw values of one property rather than wrapping them in objects:

$id = Get-Process -Name chrome | Select-Object -ExpandProperty Id

This is useful when you need a plain list of values to pass to another command.

Calculated properties

Create new properties from expressions, producing PowerShell Custom Objects:

Get-ChildItem |
Select-Object Name, @{Name="SizeKB"; Expression={$_.Length / 1KB}}

Unique values

Get-Process | Select-Object -Property Name -Unique

Select-Object is often used in pipelines to reduce the data set before passing it to the next command, such as ForEach-Object.