0
0
PowerShellscripting~5 mins

Select-Object for properties in PowerShell

Choose your learning style9 modes available
Introduction
Use Select-Object to pick only the information you want from data, making it easier to read and work with.
You want to see just a few details from a list of files, like their names and sizes.
You need to get specific information from system processes, such as process names and IDs.
You want to create a smaller list with only certain properties to use in another command.
You want to make output simpler by showing only important columns.
You want to save selected data to a file without extra details.
Syntax
PowerShell
Get-Command | Select-Object Property1, Property2, ...
Replace Property1, Property2 with the names of the properties you want to keep.
You can use Select-Object after any command that outputs objects.
Examples
Shows only the Name and Id of running processes.
PowerShell
Get-Process | Select-Object Name, Id
Displays the Status and Name of services.
PowerShell
Get-Service | Select-Object Status, Name
Lists file names and their sizes in the current folder.
PowerShell
Get-ChildItem | Select-Object Name, Length
Sample Program
This script gets running processes, picks only their Name and Id, and shows the first 3 results.
PowerShell
Get-Process | Select-Object Name, Id | Select-Object -First 3
OutputSuccess
Important Notes
Select-Object does not change the original data; it just shows selected parts.
You can use -First or -Last with Select-Object to limit how many items you see.
Property names are case-insensitive but must be spelled correctly.
Summary
Select-Object helps you focus on just the properties you need.
It works well after commands that output many details.
Use it to make output simpler and easier to understand.