Select-Object
Pick properties or the first N objects
Get-ChildItem | Select-Object -First 5 Name, Length
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Select-Object
Two jobs: cut the list (-First, -Last, -Skip) and cut the shape (-Property).
Select-Object Name, Length returns slim objects with those properties only.
Try this
Get-Process | Select-Object -First 10 Name, CPU, WorkingSet
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | ls | head -5 |
More in From bash and From cmd.