glunty

PowerShell Cheat Sheet

A searchable reference of common PowerShell cmdlets and syntax and what each one does.

Common PowerShell cmdlets and syntax with a plain-English description of what each one does
Command What it does
Get-ChildItem List the files and folders in a directory; aliases ls and dir.
Set-Location <path> Change the current working directory; alias cd.
Get-Content <file> Read a file and output its lines; aliases cat and gc.
Copy-Item <src> <dest> Copy a file or folder to another location; alias cp.
Move-Item <src> <dest> Move or rename a file or folder; alias mv.
Remove-Item <path> Delete a file or folder; aliases rm and del.
New-Item <path> Create a new file or folder; use -ItemType to choose which.
Test-Path <path> Return True or False for whether a path exists.
Get-Item <path> Get the item at a single path as an object.
cmd1 | cmd2 The pipe passes the output objects of one command as input to the next.
Where-Object <condition> Keep only the pipeline objects that match a condition; alias where.
ForEach-Object <block> Run a script block once for each object in the pipeline; aliases foreach and %.
Select-Object <props> Return objects that contain only the properties you name; alias select.
Select-Object -First 5 Take only the first N objects from the pipeline; -Last does the opposite.
Sort-Object <property> Sort pipeline objects by one or more properties; add -Descending to reverse.
Measure-Object Count objects or compute sum, average, minimum, and maximum.
Group-Object <property> Group objects that share a property value into named groups.
Get-Member List the properties and methods that an object exposes; alias gm.
Select-Object -Property Name, Length Project each object down to only the chosen properties.
$_ The current pipeline object inside a script block; also written $PSItem.
$obj.PropertyName Read a single property value from an object with dot notation.
Format-Table Display objects as an aligned table of columns; alias ft.
Format-List Display each object as a list of property and value lines; alias fl.
ConvertTo-Json Turn an object into a JSON string.
ConvertFrom-Json Parse a JSON string back into an object.
$name = "Ada" Assign a value to a variable; every variable name starts with a dollar sign.
@(1, 2, 3) Create an array with the array subexpression operator.
$arr[0] Read an array element by its zero-based index.
@{ Name = "Ada"; Age = 36 } Create a hashtable of key and value pairs.
$map["Name"] Read a hashtable value by its key.
"Hello $name" Double-quoted strings expand the variables inside them (interpolation).
"Total is $($a + $b)" Use $() to embed an expression inside a double-quoted string.
$null The absence of a value; test for it by writing $null -eq $x.
-eq / -ne Test whether two values are equal or not equal.
-gt / -lt / -ge / -le Compare which of two values is greater or smaller.
-like Match a string against a wildcard pattern that uses * and ?.
-match Match a string against a regular expression.
Get-Process List the running processes; alias ps.
Stop-Process -Name <name> Stop or kill a running process by name or id; alias kill.
Get-Service List Windows services and their running status.
Start-Service <name> Start a stopped Windows service.
Get-Command <name> Search for commands, cmdlets, functions, and aliases; alias gcm.
Get-Help <name> Show help, parameters, and examples for a command; alias help.
$env:PATH Read an environment variable through the Env provider drive.
Get-Item Env:PATH Get a single environment variable as an item object.
Invoke-WebRequest <url> Fetch a web page or call an HTTP endpoint; alias iwr.
foreach ($item in $list) { ... } Loop over every item in a collection.
for ($i = 0; $i -lt 10; $i++) { ... } Loop a set number of times using a counter.
while ($x -lt 5) { ... } Repeat a block while a condition stays true.
do { ... } while ($x -lt 5) Run the block once, then repeat while the condition holds.
if ($x -gt 0) { ... } elseif ($x -eq 0) { ... } else { ... } Branch between conditions; PowerShell spells it elseif, not elif.
switch ($x) { 1 { ... } default { ... } } Match a value against several cases with a default fallback.
function Get-Thing { param($Name) ... } Define a function that accepts named parameters.
try { ... } catch { ... } finally { ... } Run code, handle any error it throws, and always run the finally block.

Runs entirely in your browser. Nothing you type is sent anywhere; open DevTools and watch the Network tab to verify zero requests.

What this tool does

This is a searchable quick reference for the PowerShell cmdlets and syntax you reach for every day, from listing files and piping objects to writing loops, functions, and error handling. Each row pairs the exact command or construct with a plain-English note on what it does. Type in the filter box to search across both columns, or tap a category button to focus on one area. The whole list is built into the page, so it works offline and sends nothing anywhere.

How to use it

Start typing in the Filter box. Entering Where-Object surfaces the pipeline filters; entering json jumps to ConvertTo-Json and ConvertFrom-Json; entering cd finds Set-Location. The category buttons (Files, Pipeline, Objects, Variables, System, Flow control) narrow the table to one area and combine with the text filter, so you can pick Flow control and type try to zero in on error handling. Clear the box to see the full sheet again.

Common use cases

  • Recalling the exact syntax for a construct you use rarely, like a switch statement or a try/catch block.
  • Copying a cmdlet into your terminal instead of guessing its verb and noun.
  • Learning how PowerShell pipelines pass objects, not text, between commands.
  • Translating a bash habit into its PowerShell equivalent, such as ls to Get-ChildItem or cat to Get-Content.
  • Reviewing core PowerShell syntax before an interview or a new job.

Common pitfalls

  • Comparison operators are words, not symbols. Use -eq, -ne, -gt, and -lt rather than the symbols from other languages; in PowerShell the angle brackets mean redirection, not comparison.
  • Quoting changes behavior. Double-quoted strings expand variables like $name, while single-quoted strings stay literal. Reach for double quotes only when you actually want interpolation.
  • The pipeline carries objects. A value that looks like text on screen is often a rich object, so filter and sort by its properties with Where-Object and Sort-Object instead of parsing the displayed text.
  • Null comparisons go on the left. Write $null -eq $x rather than the reverse, because PowerShell handles the check more reliably when $null is on the left side of the operator.

Frequently asked questions

What is a cmdlet?
A cmdlet is a lightweight command built into PowerShell, named with a Verb-Noun pattern such as Get-Process or Set-Location. Cmdlets are compiled .NET commands that emit objects rather than plain text, which is why their output can be piped into other cmdlets and filtered by property. Because the naming stays consistent, you can often guess a command from its verb and noun.
What is $_ in the pipeline?
$_ (also written $PSItem) is the current object flowing through the pipeline. Inside a script block passed to Where-Object or ForEach-Object, $_ refers to whichever item is being processed at that moment, so $_.Name reads the Name property of the current object. It lets you write conditions and actions that run once for every item without naming a loop variable.
How do PowerShell objects differ from bash text?
In bash, commands pass around plain text, so you reach for tools like grep, awk, and cut to slice lines and columns. PowerShell passes structured objects instead, so a command like Get-Process hands you objects with real properties such as Name, Id, and CPU. You filter and sort by those properties directly with Where-Object and Sort-Object, with no fragile text parsing.
How do I filter with Where-Object?
Pipe a command into Where-Object and give it a condition that tests each item. For example, Get-Process | Where-Object CPU -gt 100 keeps only the processes using more than 100 seconds of CPU time. The longer form uses a script block and the $_ variable, such as Where-Object { $_.Status -eq "Running" }, which reads a property of the current object.
What is the difference from Command Prompt?
Command Prompt (cmd.exe) is the legacy Windows shell built around simple batch commands and text output. PowerShell is a newer, far more capable shell and scripting language that works with .NET objects, ships with thousands of cmdlets, and supports pipelines, functions, and structured error handling. PowerShell can run many old cmd commands, but the reverse is not true.
Does this cheat sheet send anything anywhere?
No. The entire command list is baked into the page and every search and filter runs locally in your browser with JavaScript, so nothing you type leaves your device. Open your browser DevTools and watch the Network tab while you search to confirm there are zero requests.

Embed this tool

Free for any use; attribution appreciated. Paste this on your site:

The embed runs the same tool that lives at this URL. No tracking; no ads inside the embed. Resize height as needed for your layout.

Cite this tool

For academic, journalistic, or technical references. Pick a format:

Citations use 2026 as the publication year. Access date is left as a fillable placeholder where the citation style expects one.

Embedded tool from glunty.com