TExcelTAD
Home › PowerShell › PowerShell Cmdlets

PowerShell Cmdlets

A cmdlet is a small, single-purpose command built into PowerShell or a module. Every cmdlet name follows the same pattern: a verb, a dash and a singular noun. Once you know the pattern you can often guess a command's name before you look it up.

Cmdlet Verb Noun Does
Get-Date Get Date reads the date
Set-Location Set Location changes folder
New-Item New Item creates a file/folder
Remove-Item Remove Item deletes it
ConvertTo-Json ConvertTo Json turns objects into JSON
Sort-Object Sort Object sorts anything

Approved verbs

Microsoft keeps a list of approved verbs so that names stay predictable: you Get and Set, never Fetch or Change. Get-Verb lists them with their group:

powershell · try it yourself
Get-Verb -Verb Get, Set, New, Remove, Start, Stop, Test, Invoke |
    ForEach-Object { '{0,-8} {1}' -f $_.Verb, $_.Group }
Get      Common
New      Common
Remove   Common
Set      Common
Test     Diagnostic
Invoke   Lifecycle
Start    Lifecycle
Stop     Lifecycle

When you write your own functions later, pick one of these verbs. PowerShell even warns you when a module exports a command with an unapproved verb.

Parameters

Cmdlets are controlled with parameters, written as a dash and a name, usually followed by a value:

powershell · try it yourself
Get-Date -Date '2026-01-15 09:30' -Format 'dddd, d MMMM yyyy HH:mm'
Get-Date -Year 2030 -Month 12 -Day 25 -Format 'yyyy-MM-dd'
Thursday, 15 January 2026 09:30
2030-12-25

Four kinds of parameters appear everywhere:

Kind Example Meaning
Named -Path ./notes.txt name and value
Positional Get-ChildItem ./logs the value alone, matched by position (-Path here)
Switch -Recurse, -Force on/off flag with no value
Common -Verbose, -ErrorAction, -WhatIf available on most cmdlets

You may shorten a parameter name as long as it is unambiguous: -Fo is enough for -Format in Get-Date, but scripts should spell names out.

Positional and switch parameters in action

powershell · try it yourself
New-Item -ItemType Directory -Path ./shop/orders -Force | Out-Null
Set-Content ./shop/orders/a.txt 'order A'          # -Path and -Value given by position
Set-Content -Path ./shop/orders/b.txt -Value 'order B'
Get-ChildItem ./shop -Recurse -File | ForEach-Object Name
Test-Path ./shop/orders/c.txt
a.txt
b.txt
False

-Force on New-Item creates missing parent folders (and doesn't complain if the folder exists). -Recurse and -File are switch parameters: their presence turns the behaviour on.

Safety switches: -WhatIf and -Confirm

Cmdlets that change something (delete files, stop services, restart computers) support -WhatIf, which only describes what would happen:

powershell · try it yourself
Set-Content ./important.txt 'do not lose me'
Remove-Item ./important.txt -WhatIf
Test-Path ./important.txt
What if: Performing the operation "Remove File" on target "/tmp/important.txt".
True

-Confirm instead asks "Are you sure?" before every change. Use -WhatIf whenever you run a destructive command for the first time, especially with wildcards like *.log.

Cmdlets vs other commands

Not everything you can run is a cmdlet. Get-Command shows the CommandType:

CommandType Example What it is
Cmdlet Get-ChildItem compiled .NET command
Function prompt, your own functions written in PowerShell
Alias gci a short name for another command
Application git, ping an external program

Everything still uses the same parameter syntax, but only cmdlets and functions return objects. External programs return lines of text.

Test yourself

Which name follows PowerShell's naming convention?

  1. Fetch-Users
  2. Get-User
  3. GetUsers
  4. users-get

What does -WhatIf do on Remove-Item?

  1. Deletes the file and reports it
  2. Asks for confirmation
  3. Shows what would be deleted without deleting it
  4. Deletes only read-only files

-Recurse is an example of which kind of parameter?

  1. Positional
  2. Switch
  3. Mandatory
  4. Dynamic