Cmdlets
PowerShell · Reference cheat sheet
Cmdlets
PowerShell · Reference cheat sheet
📋 Overview
Cmdlets are PowerShell’s native commands: Verb-Noun names, structured objects as output, and common parameters (-ErrorAction, -WhatIf, …). Discover them with Get-Command, learn them with Get-Help, and inspect objects with Get-Member.
🔧 Core concepts
| Idea | Detail |
|---|---|
| Naming | Approved verbs: Get, Set, New, Remove, Add, … |
| Discovery | Get-Command *item*, Get-Alias |
| Help | Get-Help cmd -Full, Update-Help |
| Members | Get-Member / gm |
| Common params | -Verbose, -Debug, -ErrorAction, -WhatIf, -Confirm |
| Parameters | Positional or named; tab-completion helps |
| Modules | Cmdlets ship in modules (Get-Module -ListAvailable) |
Aliases (gci → Get-ChildItem) are fine interactively; prefer full names in scripts.
💡 Examples
Discover and inspect:
Get-Command -Noun Process
Get-Help Get-Process -Examples
Get-Process | Get-Member
Get-Process pwsh | Select-Object Name, Id, CPUCommon parameters:
Remove-Item .\tmp\* -Recurse -WhatIf
Copy-Item .\a.txt .\b.txt -ErrorAction Stop
Get-ChildItem -VerboseApproved verb pattern (advanced function):
function Get-Something {
[CmdletBinding()]
param([string]$Name)
process { "Hello $Name" }
}⚠️ Pitfalls
- External programs return strings/exit codes—not objects—unless you parse them.
- Aliases differ across platforms; scripts should use canonical cmdlet names.
-Confirm/-WhatIfonly work when the command supportsSupportsShouldProcess.- Parameter binding errors often mean pipeline input type mismatch—check
Get-Help -Parameter. curl/wgetmay be aliases toInvoke-WebRequeston Windows PowerShell 5.1.- Don’t assume Linux binaries exist in Windows PowerShell sessions.