Select-Object
Use Select-Object to keep only chosen properties, take the first N objects, or expand one property into its values.
Documentation: Microsoft Learn — Select-Object
Syntax
See the command anatomy
Inspect this authored example with fictional data in the bounded browser model. The numbered stages show how its objects change.
Get-Process | Select-Object Name,Id,CPU- Stage 1Get-Process
Positional values or no named parameters - Stage 2Select-Object
Positional values or no named parameters
The object workshop
Watch your command work.
Change the command. Step through the pipeline. Inspect what survives.
Browser simulation · fictional services · Ctrl+Enter to run
Object properties
Enable JavaScript to step through this example. The lessons and command reference remain available.
Your task: return the stopped service, with exactly Name and Status.
Follow the objects
Run the command to inspect each stage.
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Select Name, Id, CPU
Show reference output
Illustrative output · values vary by environment
Name Id CPU ------- ----- ------ chrome 9184 842.31 notepad 3200 0.4 pwsh 11268 18.27 spoolsv 4400 1.4 MsMpEng 2600 950
Select first 10
Show reference output
Illustrative output · values vary by environment
Name Id ------- ----- chrome 9184 notepad 3200 pwsh 11268 spoolsv 4400 MsMpEng 2600
Select Name
Show reference output
Illustrative output · values vary by environment
Name IsStopped ---- --------- BITS False Dnscache False EventLog False Spooler False W32Time False WinRM True wuauserv False
Parameters
Parameter definitions:
-Property-ExpandProperty-Unique-First-Last-Skip
Practical use and troubleshooting
Practical scenario: Use Select-Object when you need to keep only chosen properties, take the first N objects, or expand one property into its values. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: A later filter failing to find a property can result from projecting too early. Keep the fields needed by subsequent stages and reserve the final projection for the reporting boundary. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Where-Object. Where-Object keeps matching input objects; Select-Object chooses properties or a subset of objects. Projection is different from testing whether an object satisfies a condition. Read the linked command before substituting it; similar names do not imply identical inputs or output.
FIRST REPORT · CHOOSE REPORT COLUMNS
Practise without copying
Return all automatic-start services sorted by Name, with exactly Name, DisplayName and Status. Keep the startup property until the filter has run.
How the worked example fits together
Projection decides the report contract. Keep every property needed by a later filter until that filter finishes. For this handover, DisplayName helps people identify a service, while Name remains the stable command identifier.
Get-Service | Where-Object StartType -eq 'Automatic' | Sort-Object Name | Select-Object Name, DisplayName, StatusThe report has a deliberate schema and a stable row order. StartType is needed for filtering but does not have to appear in the final report.
Bounded browser simulation · fictional services · no computer or tenant access.
Predict the result, write your pipeline, then run it.
Put this command to work
Write your first report
Save Name and Status for all services to C:\Lab\report.csv without type information.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.
Inspect starting data
Supported syntax
Virtual files
Recap
Select-Object Use Select-Object to keep only chosen properties, take the first N objects, or expand one property into its values.
Next: Where-Object