PowerShell Cheat Sheet — Commands You Can Copy

The PowerShell commands developers and admins use every day on Windows — and in PowerShell 7 on macOS and Linux — explained in one line each. Type your folder, file and host once and copy ready-to-run commands.

Runs in your browserUpdated
Your valuesEvery example below updates as you type

Help & discovery

5
Get-Command *service*

Find commands whose name contains a word — the fastest way to discover cmdlets.

Get-Help Get-Process -Examples

Show usage examples for a cmdlet. Run Update-Help once to download full help.

Get-Process | Get-Member

List the properties and methods of the objects a command returns.

Get-Alias ls

See which cmdlet an alias runs (ls, dir and gci all run Get-ChildItem).

$PSVersionTable

Show the PowerShell version and edition (Windows PowerShell 5.1 or PowerShell 7).

Files & folders

11
Get-ChildItem C:\Projects\app -Recurse -Filter *.log

List files of one type in a folder and its subfolders.

Set-Location C:\Projects\app

Change the current folder (alias cd).

New-Item -ItemType Directory -Path C:\Projects\app\logs -Force

Create a folder, including missing parent folders.

Copy-Item app.log C:\Projects\app\backup\ -Force

Copy a file, overwriting an existing copy.

Move-Item app.log C:\Projects\app\archive\

Move or rename a file or folder.

Remove-Item C:\Projects\app\temp -Recurse -Force

destructive Delete a folder and everything in it without asking.

Get-Content app.log -Tail 50 -Wait

Show the last 50 lines of a file and keep following new lines (like tail -f).

Set-Content app.log -Value "text" -Encoding utf8

destructive Write text to a file, replacing its content.

Add-Content app.log -Value "another line"

Append a line to a file.

Compress-Archive -Path C:\Projects\app\* -DestinationPath archive.zip

Create a ZIP file from a folder’s contents.

Expand-Archive archive.zip -DestinationPath C:\Projects\app

Extract a ZIP file.

Search & text

7
Select-String -Path *.log -Pattern "error"

Search files for text or a regex (like grep); shows file, line number and line.

Get-ChildItem -Recurse | Select-String "error" -List

Find which files under the folder contain the text.

(Get-Content app.log) -replace "old", "new" | Set-Content app.log

destructive Find and replace text in a file (regex supported).

Get-Content app.log | Measure-Object -Line -Word -Character

Count lines, words and characters (like wc).

Import-Csv data.csv | Where-Object { $_.Status -eq "active" }

Read a CSV as objects and filter rows by a column.

Get-Process | Export-Csv processes.csv -NoTypeInformation

Save any command’s output as a CSV file.

Get-Content data.json -Raw | ConvertFrom-Json

Parse a JSON file into objects you can query.

Processes & services

6
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10

Show the 10 processes using the most CPU time.

Stop-Process -Name node -Force

destructive Kill all processes with that name.

Get-Service | Where-Object Status -eq Running

List running Windows services.

Restart-Service Spooler

Restart a service (needs an elevated shell).

Start-Process pwsh -Verb RunAs

Open a new PowerShell window as administrator.

Get-NetTCPConnection -LocalPort 443 | Select-Object OwningProcess

Find which process is listening on a port.

Network & web

5
Test-NetConnection example.com -Port 443

Check whether a host is reachable on a TCP port (ping + port test).

Resolve-DnsName example.com

Look up DNS records for a host name.

Invoke-RestMethod https://api.github.com/repos/owner/repo

Call a JSON API and get the response as objects.

Invoke-WebRequest https://example.com/file.zip -OutFile file.zip

Download a file.

Get-NetIPAddress -AddressFamily IPv4

Show this computer’s IPv4 addresses.

Variables, pipeline & scripting

8
$env:PATH -split ";"

Show each folder on the PATH on its own line.

$env:API_URL = "value"

Set an environment variable for the current session.

[Environment]::SetEnvironmentVariable("API_URL", "value", "User")

Set an environment variable permanently for your user.

Get-ChildItem | ForEach-Object { $_.Name.ToUpper() }

Run code for every item in the pipeline ($_ is the current item).

Get-ChildItem | Where-Object Length -gt 10MB

Filter objects by a property — here, files larger than 10 MB.

Measure-Command { Get-Process }

Time how long a command takes.

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Allow local scripts to run for your user; downloaded scripts must be signed.

try { Get-Process -ErrorAction Stop } catch { Write-Warning $_ }

Catch errors — -ErrorAction Stop turns non-terminating errors into catchable ones.

System

5
Get-ComputerInfo -Property OsName, OsVersion, CsTotalPhysicalMemory

Show the Windows version and installed memory.

Get-PSDrive -PSProvider FileSystem

Show drives with used and free space.

Get-WinEvent -LogName System -MaxEvents 20

Read the latest System event log entries.

winget upgrade --all

Update all apps installed with the Windows Package Manager.

Restart-Computer -Force

destructive Restart the computer immediately.

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the PowerShell Cheat Sheet

  1. Type your own values (folder, file, host) in the boxes at the top — every example on the page updates instantly.
  2. Search or jump to a section to find the command you need.
  3. Click Copy to copy a ready-to-run line, or Copy section for a commented block.
  4. Commands marked destructive delete or overwrite data — read the note before running them.

Objects, not text

The big difference from Bash and CMD: PowerShell commands pass objects down the pipeline, not lines of text. Get-Process | Where-Object CPU -gt 100 | Sort-Object CPU filters and sorts on real properties — no parsing of columns. Get-Member shows what properties an object has, and Select-Object, Where-Object and ForEach-Object do the rest.

Verb-Noun names and aliases

Cmdlets are named Verb-Noun — Get-ChildItem, Set-Content, Remove-Item — so Get-Command -Verb Get or Get-Command *Service* finds what you need. Familiar aliases such as ls, cd, cat and rm map to these cmdlets, but their parameters are PowerShell’s, not Unix flags.

Windows PowerShell 5.1 vs PowerShell 7

Windows ships with Windows PowerShell 5.1 (powershell.exe). PowerShell 7 (pwsh) is the cross-platform successor for Windows, macOS and Linux, with the && and || operators, ternaries and better performance. Everything on this page works in both unless noted. Compare with the CMD cheat sheet and the Linux commands cheat sheet.

Tools that pair well with the PowerShell Cheat Sheet

  • Git Cheat Sheet — Every Git command you use day to day — and the ones you need when something goes wrong — explained in one line.
  • Windows Path Converter — Paste a path in any format — C:\Users\me\project, /mnt/c/Users/me/project, /c/Users/me — and get it in every other form, ready to copy: WSL, Git Bash, Cygwin, file URL, UNC and escaped for code.
  • Line Ending Converter — See which line endings a file uses and convert them — Windows CRLF to Unix LF or back — for pasted text or a whole batch of files, with trailing-space and tab cleanup on the side.
  • Docker Cheat Sheet — The Docker and Docker Compose commands you reach for every week, explained in one line.

Frequently asked questions

What is the PowerShell equivalent of grep?
Select-String. For example Select-String -Path *.log -Pattern "error", or pipe output into it: Get-Content app.log | Select-String error.
How do I follow a log file like tail -f?
Get-Content app.log -Tail 50 -Wait shows the last 50 lines and keeps printing new ones.
Why won’t my script run?
The execution policy blocks scripts by default. Run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser to allow your own scripts.
Can I install PowerShell Cheat Sheet as a web app and use it offline?
Yes. PowerShell Cheat Sheet is an installable web app (PWA) — installed from your browser, not downloaded from an app store. Click Install app at the top of this page in Chrome or Edge (Windows, macOS, Linux, ChromeOS) or on Android, use Share → Add to Home Screen on iPhone and iPad, or File → Add to Dock in Safari 17+ on a Mac. It then opens in its own window with its own icon, and because it runs entirely in your browser it keeps working offline. Firefox on desktop can’t install web apps. How installing works.

Related tools