Code Reference

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

IdeaDetail
NamingApproved verbs: Get, Set, New, Remove, Add, …
DiscoveryGet-Command *item*, Get-Alias
HelpGet-Help cmd -Full, Update-Help
MembersGet-Member / gm
Common params-Verbose, -Debug, -ErrorAction, -WhatIf, -Confirm
ParametersPositional or named; tab-completion helps
ModulesCmdlets ship in modules (Get-Module -ListAvailable)

Aliases (gciGet-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, CPU

Common parameters:

Remove-Item .\tmp\* -Recurse -WhatIf
Copy-Item .\a.txt .\b.txt -ErrorAction Stop
Get-ChildItem -Verbose

Approved 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 / -WhatIf only work when the command supports SupportsShouldProcess.
  • Parameter binding errors often mean pipeline input type mismatch—check Get-Help -Parameter.
  • curl / wget may be aliases to Invoke-WebRequest on Windows PowerShell 5.1.
  • Don’t assume Linux binaries exist in Windows PowerShell sessions.

On this page