This command shows running processes with selected columns and sorts them by CPU usage/time.
Get-Process | Select Name,Id,CPU | Sort CPU -Descending
Meaning step by step
1. Get-Process
Get-Process
Gets all running processes on the computer.
2. Pipeline |
|
Passes the process objects to the next command.
3. Select Name,Id,CPU
Select Name,Id,CPU
Short form of:
Select-Object Name, Id, CPU
It displays only these properties:
| Property | Meaning |
|---|---|
Name | Process name |
Id | Process ID |
CPU | Total CPU seconds used by the process |
4. Sort CPU -Descending
Sort CPU -Descending
Short form of:
Sort-Object CPU -Descending
It sorts the output by CPU from highest to lowest.
Full meaning
Get-Process | Select Name,Id,CPU | Sort CPU -Descending
means:
Get all running processes, show only Name, Id, and CPU, then sort them from highest CPU time to lowest CPU time.
Better formal version
Get-Process |
Select-Object Name, Id, CPU |
Sort-Object CPU -Descending
Student comment
# This command lists running processes, selects only the Name, Id, and CPU properties,
# and sorts the results by CPU usage in descending order.
Ref: AI Tools/ChatGPT
