All cheatsheets

PowerShell Commands Cheat Sheet

Quick reference for PowerShell cmdlets: discovery, file/system, pipeline filtering and selection, networking, remote sessions and modules — with common parameters and practical examples.

34 commands

Discovery & Help

Get-Command [<name>]

Discover commands by name, alias, or wildcard — really the 'man' of PowerShell.

-Module <module>; -Noun / -Verb; -ParameterType; -All

Get-Command -Noun Service | Format-Table Name, Module
Get-Help <cmdlet> [-Examples|-Detailed|-Full]

Show help for a cmdlet: synopsis, syntax, parameters, examples.

-Examples; -Detailed; -Full; -Online open browser; -ShowWindow GUI

Get-Help Get-Process -Examples
Get-Module [-ListAvailable]

List modules loaded into the session (or available for import).

-ListAvailable; -All; -Name filter

Get-Module -ListAvailable | Sort-Object Name

Navigation & FS

Set-Location / Get-Location / pwd

Change or print the current working directory.

Set-Location C:\projects\app; Get-Location
Get-ChildItem (alias ls/dir)

List files and subdirectories (recursively with -Recurse).

-Recurse; -Force hidden; -Filter <pattern>; -File / -Directory; -Depth

Get-ChildItem -Recurse -File -Filter *.log | Sort-Object Length -Descending | Select-Object -First 10
New-Item -ItemType File/Directory <path>

Create a new file or directory (default: file).

-Force overwrite/create parents; -ItemType File|Directory|SymbolicLink; -Value content

New-Item -ItemType Directory -Path logs/2026 | Out-Null
Remove-Item (alias rm/del)

Delete files, directories, registry keys, or variables.

-Recurse; -Force; -Confirm:\$false to skip prompts

Remove-Item -Recurse -Force build/, node_modules/
Copy-Item / Move-Item / Rename-Item

Copy, move or rename filesystem items.

-Recurse; -Force; -To; -Exclude / -Include filters

Copy-Item -Recurse dist\* \\deploy\shares\app\
Get-Content / Set-Content / Add-Content

Read or write file content (Get-Content with -Tail behaves like Unix tail).

-Tail N; -Wait follow; -TotalCount N; -Encoding utf8/ASCII

Get-Content -Path app.log -Tail 50 -Wait
Test-Path / Resolve-Path

Check if a path exists (file, dir, registry) or resolve wildcards.

-PathType Container|Leaf; -IsValid

if (Test-Path .\node_modules) { Remove-Item -Recurse .\node_modules }

Pipeline & Objects

Where-Object (alias ?)

Filter objects in the pipeline by a property or script block.

-Property / -Value pattern match; -Like / -EQ / -GT ...; -CContains / -In

Get-Process | Where-Object { $_.WorkingSet64 -gt 200MB }
Select-Object (alias select)

Choose specific properties, deduplicate, or expand to N items.

-Property names; -First / -Last N; -Skip N; -Unique; -ExpandProperty

Get-Service | Select-Object Name, Status, StartType | Format-Table
ForEach-Object (alias %)

Perform an action on each object arriving in the pipeline.

-Begin / -Process / -End; -Parallel on PS7+

Get-ChildItem *.csv | ForEach-Object { Import-Csv $_ | Group-Object Level }
Sort-Object (alias sort)

Sort pipeline objects by one or more properties.

-Property; -Descending

Get-ChildItem | Sort-Object -Property Length -Descending | Select -First 5
Group-Object (alias group)

Group objects by a property value; `-NoElement` yields just counts.

-Property; -NoElement; -CaseSensitive

Get-Content app.log | Group-Object | Sort-Object Count -Descending
Measure-Object (alias measure)

Compute numeric statistics (count, sum, min/max/avg) for a property.

-Sum / -Average / -Minimum / -Maximum; -Line / -Word / -Character for text

Get-ChildItem -File -Recurse | Measure-Object -Property Length -Sum

Formatting

Format-Table / Format-List (ft / fl)

Render pipeline objects as a table or a list — for display only.

-AutoSize; -Wrap; -GroupBy; -Property subset

Get-Process | Format-Table Name, Id, @{n='Mem(MB)';e={[Math]::Round($_.WorkingSet64/1MB,1)}} -AutoSize
Out-File / Set-Content / Tee-Object

Write output to a file; Tee-Object writes both to a file and the pipeline.

Get-Service | Tee-Object -FilePath services.txt | Where-Object { $_.Status -eq 'Running' }

Strings & Variables

Select-String (alias sls)

Grep equivalent — find lines matching a pattern (regex-aware).

-Path; -Pattern; -SimpleMatch; -CaseSensitive; -Context N

Select-String -Path src\**\*.ts -Pattern 'TODO' -CaseSensitive:\$false
Set-Variable (alias set/sv)

Define a session or environment variable.

-Name; -Value; -Scope Global|Local|Script; -PassThru

Set-Variable -Name regions -Value @('eastus','westus') -Scope Global
Get-Variable / $env:

List or read variables; read/write process environment via $env: drive.

$env:DATABASE_URL = 'postgres://localhost/dev'; Get-Variable | Out-GridView
Get-Alias / Set-Alias

List or define custom shortcuts for cmdlets.

Set-Alias -Name grep -Value Select-String -Option ReadOnly -Scope Global

Processes & Services

Get-Process / Start-Process / Stop-Process

Inspect, start or stop local processes (Stop-Process = kill).

-Name; -Id; -FileVersionInfo; -PassThru; -Force for kill

Get-Process node | Sort-Object -Property WorkingSet64 -Descending | Select -First 5
Get-Service / Start-Service / Stop-Service

Inspect, start or stop Windows services.

-Name; -DisplayName; -Status Running|Stopped

Get-Service | Where-Object Status -eq Stopped | Format-Table Name, StartupType

Networking

Test-NetConnection <host>

Diagnose TCP connectivity, latency, and (with -Port) reachability.

-Port; -InformationLevel Detailed; -DiagnoseRouting

Test-NetConnection api.example.com -Port 443
Invoke-WebRequest / Invoke-RestMethod

HTTP client (RestMethod parses JSON straight into objects).

-Method GET/POST/PUT/DELETE; -Headers @{...}; -Body (json); -OutFile path; -SkipHttpRedirect; -UseBasicParsing

Invoke-RestMethod -Uri https://api.github.com/repos/powershell/powershell/releases/latest | Select-Object tag_name, html_url
Resolve-DnsName / Get-NetIPAddress

Resolve DNS records and inspect local IP configuration.

-Type A/AAAA/MX/CNAME; -Server 8.8.8.8; -AddressFamily IPv4/IPv6

Resolve-DnsName example.com -Type MX

Remote & Module

Enter-PSSession / Invoke-Command

Start or run a command on remote machines (WinRM / SSH).

-ComputerName / -HostName; -Credential; -ConfigurationName; -FilePath

Invoke-Command -ComputerName web01,web02 -FilePath .\deploy.ps1
Import-Module / Find-Module / Install-Module

Load a module into the session or fetch it from a repository.

-Force reload; -Scope Global/CurrentUser; -AcceptLicense; -AllowClobber

Install-Module -Name Az -Scope CurrentUser -AcceptLicense
Get-Module / Remove-Module

List loaded modules or unload one from the session.

Get-Module | Format-Table Name, Version, ExportedCommands.Count

System

Get-Date / Set-Date

Read or change the current date/time with rich formatting.

-Format; -UFormat; -DisplayHint; -Culture

Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
Get-CimInstance Win32_OperatingSystem

Hardware/system info via CIM/WMI (memory, disk, OS, BIOS, etc.).

-ClassName; -ComputerName; -Filter query

Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'" | Select DeviceID, @{n='FreeGB';e={[Math]::Round($_.FreeSpace/1GB,2)}}
Get-History / Invoke-History (alias h/r)

Replay recently run commands in the current session.

-Count N; -Id N to rerun a specific entry

Get-History | Where-Object CommandLine -like 'Get-*' | Invoke-History
$PROFILE / Update-Help

Edit your profile (startup script) and refresh cmdlet help.

notepad $PROFILE; Update-Help -Force

Cheatsheet version 1.0.0

Covers PowerShell 7+