Useful Commands
PowerShell · Reference cheat sheet
Useful Commands
PowerShell · Reference cheat sheet
📋 Overview
A compact toolkit of high-frequency PowerShell commands for files, processes, networking, and discovery. Prefer cmdlets in scripts; aliases are fine interactively. PowerShell 7+ (pwsh) is recommended for cross-platform work.
🔧 Core concepts
| Area | Go-to cmdlets |
|---|---|
| Files | Get-ChildItem, Copy-Item, Move-Item, Remove-Item, Get-Content, Set-Content |
| Search | Select-String, Where-Object |
| Process | Get-Process, Stop-Process, Start-Process |
| Net | Test-Connection, Test-NetConnection, Invoke-WebRequest |
| System | Get-Service, Get-ComputerInfo (Win) |
| Help | Get-Help, Get-Command, Get-Member |
| Path | Join-Path, Resolve-Path, Split-Path, Test-Path |
Operators: -replace, -split, -join, redirection >, >>, 2>, *>.
💡 Examples
Files and search:
Get-ChildItem -Recurse -Filter *.md |
Select-String -Pattern 'TODO' |
Select-Object Path, LineNumber, Line
Get-Content .\app.log -Tail 50 -WaitProcesses and ports (Win):
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10
Test-NetConnection example.com -Port 443
Get-NetTCPConnection -State Listen | Select-Object LocalPort, OwningProcessQuick JSON / clipboard (Win):
Invoke-RestMethod https://api.github.com/zen
Set-Clipboard (Get-Location).PathDiscovery:
Get-Command *Item*
Get-Help about_Operators⚠️ Pitfalls
rm,ls,catare aliases—behavior differs from GNU tools.Remove-Item -Recursewithout-Forcemay prompt; in PS 5.1-Recursequirks exist—test first.curlalias confusion on Windows PowerShell 5.1.- Prefer
-LiteralPathwhen names contain[wildcards. - Admin-required cmdlets fail silently or access-denied—check elevation.
- Don’t use
Write-Hostwhen you need pipeline data.