A compact PowerShell quick reference for everyday administration, troubleshooting and automation — rebuilt from the complete cheat sheet PDF. Run the live pipeline demos: every result is computed in your browser from fictional sample data.
Essential command patterns
Ten patterns cover most daily work. Press Run pipeline on a demo to watch fictional objects flow through each stage — click a stage to inspect its rows.
1. Discover commands
Discover what is actually available in your session before guessing names. Availability depends on installed modules.
2. Inspect objects — console columns are only a view
The table you see is a view. The object keeps every property until you deliberately select or format them.
| Name | svchost |
| Status | Running |
| StartType | Automatic |
| DisplayName | Host Process for Windows Services |
Get-Member lists these properties for any object you meet.
3. Filter — keep objects whose properties match
Where-Object chooses objects (rows). It never changes the state of anything — it only keeps matches.
Get-Service | Where-Object { $_.Status -eq 'Running' }Press Run — objects flow through each stage. Fictional sample data.
4. Sort, then limit — CPU here is cumulative seconds
Top-N questions need an ordering first — -First is meaningless without a sort. CPU is accumulated processor time in seconds, not live CPU %.
Get-Process | Sort-Object CPU -Descending | Select-Object -First 3 Name, CPUPress Run — objects flow through each stage. Fictional sample data.
5. Measure — working-set memory in bytes
WorkingSet64 is bytes. Convert units explicitly when you present the number to a human.
Get-Process | Measure-Object -Property WorkingSet64 -SumPress Run — objects flow through each stage. Fictional sample data.
6. Group — count services in each status
Group-Object answers “how many of each” in one pass — no manual counting loops.
Get-Service | Group-Object Status | Select-Object Name, CountPress Run — objects flow through each stage. Fictional sample data.
7. Files — inspect the current directory
-File skips directories. You still have objects — Length and LastWriteTime sort and filter cleanly.
8. Strings — double quotes expand, single quotes stay literal
Double-quoted strings expand variables; single-quoted strings preserve literal text. Pick deliberately.
$topic = 'PowerShell'Pick a quoting style to evaluate it.
9. Export objects — never Format-Table before Export-Csv
Export-Csv needs structured objects. Format-* output is display text — piping it to Export-Csv exports garbage.
10. Handle errors — catch sees terminating errors
-ErrorAction Stop promotes the error to terminating so catch can see it. Without it, catch never fires.
Four principles that prevent mistakes
01 · Discover before guessing
Use Get-Command and Get-Help to inspect the command that is actually available in your session.
02 · Keep objects structured
Filter, sort, select, measure, and export object properties. Never parse formatted console text when object properties exist.
03 · Filter before formatting
Where-Object chooses objects. Select-Object chooses properties or limits rows. Format-* is for final display only.
04 · Sort before top-N
If the question asks for the largest, smallest, busiest, or newest objects, sort first — then select the first rows.
Task index
Eight rules worth memorizing
- Inspect first.
Use Get-Member when you do not know which properties an object exposes.
- Filter with properties.
Where-Object should compare real properties such as Status, Name, CPU, or WorkingSet64.
- Select deliberately.
Select-Object chooses properties and can limit rows — two different jobs.
- Sort before top rows.
Top-N questions require an ordering before -First is meaningful.
- Export objects.
Export-Csv must receive structured objects, never Format-Table output.
- Know units.
WorkingSet64 is bytes; CPU is accumulated seconds. Convert explicitly.
- Know scope.
Commands depend on Windows, modules, tenant context, permissions, and edition.
- Discover safely.
Get-Help -Examples and Get-Command -Syntax are cheap ways to confirm intent before running anything that changes a system.
See the pipeline move
Six sketches from the complete cheat-sheet PDF, redrawn as step-through diagrams. Each plays once when it scrolls into view — step with ← → or the Prev / Next buttons.
Read a command like a sentence
Verb, noun, details — read a command left to right, like a sentence.
A row is a view, not the object
Console columns are a view. The object keeps every property.
Where-Object is a sieve
Filtering chooses rows. It never changes the state of anything.
Sort before taking the top rows
Top-N questions need an ordering before -First means anything.
Pass objects along the pipeline
Each object travels the whole pipeline, properties intact.
Export objects, not a drawn table
Format-* is for final display. Export needs objects, not text.
Diagrams are conceptual illustrations, not executions. Demo data on this page is fictional.