PowerShell Cheat Sheet
A reference for Windows PowerShell, discovering cmdlets, the object pipeline, filtering and formatting, managing files, processes and services, plus variables and flow control.
A reference for Windows PowerShell. Commands are cmdlets in
Verb-Noun form (e.g. Get-Process) and most accept objects through
the pipe. Run Get-Help CMDLET -Examples for examples.
Discovering commands
| Cmdlet | What it does |
|---|---|
Get-Command *service* | Find cmdlets by name |
Get-Help CMDLET | Show help for a cmdlet |
Get-Member | List an object's properties & methods |
Get-Alias | List shortcut aliases (e.g. ls, cd) |
Files & navigation
| Cmdlet | What it does |
|---|---|
Get-ChildItem | List items (alias ls/dir) |
Set-Location PATH | Change directory (alias cd) |
Get-Content FILE | Read a file (alias cat) |
Set-Content FILE "text" | Write text to a file |
Copy-Item SRC DEST -Recurse | Copy files or folders |
Remove-Item PATH -Recurse -Force | Delete items (careful) |
Test-Path PATH | Check if a path exists |
The pipeline & filtering
| Cmdlet | What it does |
|---|---|
Where-Object { $_.CPU -gt 10 } | Filter objects by a condition |
Select-Object Name, Id | Pick specific properties |
Sort-Object CPU -Descending | Sort objects |
Measure-Object -Sum | Count / sum / average values |
ForEach-Object { $_ * 2 } | Run a block for each item |
... | Format-Table -AutoSize | Display results as a table |
System & processes
| Cmdlet | What it does |
|---|---|
Get-Process | List running processes |
Stop-Process -Name app -Force | Kill a process |
Get-Service | List Windows services |
Start-Service -Name w32time | Start a service (Stop-Service to stop) |
Get-ComputerInfo | OS and hardware details |
Variables & flow
| Syntax | What it does |
|---|---|
$x = 5 | Assign a variable |
$items = @(1,2,3) | Create an array |
if ($x -gt 3) { ... } | Conditional (-eq -ne -lt -gt -like) |
foreach ($i in $items) { ... } | Loop over a collection |
Invoke-WebRequest URL | Download / call a URL (alias iwr) |
Run scripts with .\script.ps1. If blocked, set the policy
for your session: Set-ExecutionPolicy -Scope Process RemoteSigned. Use
Tab to complete cmdlet and parameter names.
What this does
A PowerShell cheat sheet covers discovering cmdlets, the object pipeline, filtering and formatting, managing files and services, and flow control.
How to use it
- Browse by section.
- Find the cmdlet you need.
- Copy it with one tap.
- Adapt the parameters.
Example
Get-Process | Sort-Object CPU -Descending lists the busiest processes.
Sources & methodology
Last updated .
Frequently asked questions
What is a cmdlet?
A cmdlet is a built-in PowerShell command named in Verb-Noun form, such as Get-Process or Set-Location. Most accept and emit objects, which is what makes the pipeline so powerful.
Why won’t my script run?
The execution policy may be blocking it. For the current session, run Set-ExecutionPolicy -Scope Process RemoteSigned, then run your script.
Do my old CMD commands still work?
Many do, because PowerShell defines aliases like ls, cd, and cat. For full functionality, learn the underlying cmdlets they point to.
Related tools
Linux Command Cheat Sheet
The essential Linux terminal commands on one page, files and navigation, permissions, processes, networking, and package managers. A quick reference for the bash shell.
Windows CMD Cheat Sheet
A quick reference for the Windows Command Prompt, file and folder commands, networking, disk and system tools, plus handy keyboard shortcuts.
macOS Terminal Cheat Sheet
A reference for the macOS Terminal, the Mac-only commands (open, pbcopy, mdfind), system and defaults tools, Homebrew, core Unix commands, and keyboard shortcuts.
IBM AS/400 (IBM i) Cheat Sheet
A reference for the IBM i (AS/400, OS/400) command line, the work-with commands, libraries and objects, spooled files and output queues, messages, and 5250 function-key shortcuts.