PowerShell Cheat Sheet
Searchable reference for everyday PowerShell cmdlets.
| Cmdlet | Description |
|---|---|
| Get-ChildItem | List items (alias: ls, dir) |
| Get-ChildItem -Recurse -Filter *.cs | Recursive file search |
| Get-ChildItem -Force | Include hidden items |
| Set-Location | Change directory (alias: cd) |
| Get-Location | Print working directory (alias: pwd) |
| Push-Location ; Pop-Location | Save and restore location |
| Resolve-Path .\f | Expand to absolute path |
| Get-Item <path> | Format-List * | All metadata for an item |
| New-Item -Type Directory p | Create folder |
| New-Item -ItemType File f | Create empty file |
| Remove-Item -Recurse -Force p | Recursive delete |
| Copy-Item -Recurse a b | Copy folder |
| Move-Item a b | Move / rename |
| Rename-Item old new | Rename in place |
| New-Item -ItemType SymbolicLink -Path link -Target tgt | Symbolic link |
| Get-Content <file> | Read file (alias: cat) |
| Get-Content f -Tail 20 -Wait | Follow file (like tail -f) |
| Get-Content f -TotalCount 20 | First 20 lines |
| Set-Content -Path f -Value 'x' | Write string to file |
| Add-Content -Path f -Value 'x' | Append to file |
| Out-File -FilePath f -Encoding utf8 | Write file as UTF-8 |
| Select-String 'pat' f | Grep equivalent |
| Select-String -Pattern 'pat' -Path *.cs -CaseSensitive | Case-sensitive search |
| (Get-Content f) -replace 'foo','bar' | Set-Content f | In-place replace |
| ForEach-Object { ... } | Pipeline loop |
| Where-Object { $_.Foo -eq 1 } | Pipeline filter |
| ? Name -like '*x*' | Where-Object short syntax |
| Select-Object -First 5 | Take first N |
| Select-Object -Property Name,Size | Project properties |
| Sort-Object Foo -Descending | Sort by property |
| Group-Object Foo | Group by property |
| Measure-Object -Line | Count lines |
| Measure-Object Size -Sum -Average | Numeric aggregates |
| Get-Process | ? Name -like '*app*' | Find process |
| Stop-Process -Id 1234 -Force | Kill process |
| Stop-Process -Name app -Force | Kill all by name |
| Start-Process -Verb RunAs | Run elevated |
| Start-Process -FilePath app.exe -ArgumentList 'a','b' | Launch with args |
| Get-Service | ? Status -eq 'Running' | Running services |
| Restart-Service -Name svc | Restart Windows service |
| $env:VAR = 'value' | Set env var (session) |
| [Environment]::SetEnvironmentVariable('VAR','v','User') | Persist user env var |
| Get-ChildItem env: | Sort Name | List all env vars |
| Remove-Item env:VAR | Unset env var |
| Get-PSDrive | List filesystem-like drives |
| Get-Volume | Show volume sizes |
| Get-ComputerInfo | Select OsName,OsVersion | OS info |
| Get-Date | Current date / time |
| (Get-Date) - (Get-Date '2025-01-01') | Time span between dates |
| Compress-Archive a -DestinationPath a.zip | Make zip |
| Expand-Archive a.zip -DestinationPath . | Extract zip |
| Invoke-WebRequest -Uri url | HTTP fetch (alias: curl) |
| Invoke-WebRequest -Uri url -OutFile f | Download to file |
| Invoke-RestMethod -Uri url | Auto-parse JSON response |
| Test-NetConnection host -Port 443 | TCP port check |
| Resolve-DnsName example.com | DNS lookup |
| ConvertFrom-Json | Parse JSON string |
| ConvertTo-Json -Depth 10 | Serialise to JSON, deep |
| Import-Csv f.csv | Parse CSV to objects |
| Export-Csv f.csv -NoTypeInformation | Write objects to CSV |
| ConvertFrom-StringData | Parse key=value text |
| Test-Path <path> | Does it exist? |
| Split-Path -Leaf <path> | Get filename portion |
| Join-Path a b c | Combine path segments |
| Get-Command <name> | Find a command |
| Get-Help <cmd> | Show help |
| Get-Help <cmd> -Examples | Just the examples block |
| Get-Member | Inspect object members |
| Get-Alias | List aliases |
| Get-History | Command history |
| Set-ExecutionPolicy -Scope CurrentUser RemoteSigned | Allow signed remote scripts |
| $ErrorActionPreference = 'Stop' | Make errors terminating |
| try { ... } catch { ... } finally { ... } | Structured exception handling |
About this tool
Verb-Noun cmdlets for file system, process, pipeline, archives and HTTP — with one-line descriptions and common aliases.