Cmdlets and Syntax

Reviewed & published by Brayan K

By the end of this lesson you'll read any cmdlet's name and know what it does, discover new ones without Googling, and drive them precisely with parameters and aliases — the skill that unlocks the entire 1,400+ cmdlet PowerShell toolbox.

Part of the free PowerShell course at LearnCodingFast — hands-on lessons with worked examples and the output they print, plus practice exercises and a quick quiz.

What You'll Learn

💡 Real-World Analogy

Think of cmdlets as a well-organised toolbox where every tool is labelled action + object: "tighten-bolt", "loosen-bolt", "cut-pipe". You'd never need an index — reading the label tells you exactly what each tool does, and if you want to loosen something you already know the label starts with "loosen". PowerShell is built this way on purpose: Get-Service, Stop-Service, Restart-Service. Learn the handful of verbs and you can predict command names instead of memorising 1,400 of them.

1. The Verb-Noun Structure

Every cmdlet (PowerShell's word for a built-in command) is named Verb-Noun. The verb is the action; the noun is what it acts on, and the noun is always singular. Microsoft publishes a list of approved verbs so the vocabulary stays consistent: Get- retrieves, Set- changes, New- creates, Remove- deletes. Once that clicks, a name like Get-Service needs no explanation. Read this worked example, then run it.

# Every cmdlet is named Verb-Noun. The verb is the action,
# the noun is the thing you act on. Read these four out loud:

Get-Process     # Get  = retrieve  | Process = running programs
Get-Service     # Get  = retrieve  | Service = background services
New-Item        # New  = create    | Item    = a file or folder
Remove-Item     # Remove = delete  | Item    = a file or folder

# Get-Verb lists the APPROVED verbs. Look at a few common ones:
Get-Verb Get, Set, New, Remove | Select-Object Verb, Group

Run Get-Verb any time to see the full approved list. Sticking to these verbs is not just style — PowerShell prints a warning when a module uses an unapproved verb, because non-standard names are exactly what break the "guessable" promise.

2. Discovering Cmdlets (don't guess — find)

You are not expected to know every cmdlet. Three discovery tools cover almost everything. Get-Command finds cmdlets — filter by -Verb or -Noun to zero in. Get-Help <name> -Examples shows copy-paste usage for one cmdlet. Get-Member pipes an object in and lists the properties and methods it actually has, so you know what you can sort or filter on. This trio is the most important habit in the whole language.

# You don't memorise cmdlets — you DISCOVER them. Three tools do it all.

# 1) Get-Command: find cmdlets. -Noun filters to one target.
Get-Command -Noun Service -CommandType Cmdlet | Select-Object -First 4 Name

# 2) Get-Help -Examples: see real usage you can copy.
Get-Help Get-Service -Examples

# 3) Get-Member: list the properties/methods an object actually has.
Get-Service | Get-Member -MemberType Property | Select-Object -First 3 Name

Now you try. The program below is almost complete — fill in the two blanks marked ___ using the hints in the comments, then run it.

# 🎯 YOUR TURN — replace each ___ then run it.
# Goal: discover which cmdlets work on "Process".

# 1) Ask Get-Command for every cmdlet whose NOUN is Process
$found = Get-Command -Noun ___ -CommandType Cmdlet   # 👉 the noun, written as Process

# 2) Show just their names, sorted
$found | Select-Object -ExpandProperty ___ | Sort-Object   # 👉 the property is Name

# ✅ Expected output:
# Debug-Process
# Get-Process
# Start-Process
# Stop-Process
# Wait-Process

3. Parameters & Parameter Sets

A parameter customises what a cmdlet does. It starts with a dash. There are three flavours you'll meet constantly: a named parameter is spelled out (-Path C:\Temp) and order doesn't matter; a positional parameter can drop its name because PowerShell knows it by position (-Path is position 0 for Get-ChildItem); and a switch is an on/off flag with no value (-Recurse). Many cmdlets also define parameter sets — groups of parameters that can't be mixed (e.g. ask for a service by -Name or by -DisplayName, not both). Run Get-Command <name> -Syntax to see them; positional parameters show as [[-Name] <type>].

# A parameter customises a cmdlet. It starts with a dash: -Name value.

# NAMED parameter — you spell out the name. Order doesn't matter.
Get-ChildItem -Path C:\Temp -Filter *.log

# POSITIONAL parameter — -Path is position 0, so you can drop the name.
# These two lines do EXACTLY the same thing:
Get-ChildItem -Path C:\Temp
Get-ChildItem C:\Temp

# SWITCH parameter — a flag. Its presence alone means $true (no value).
Get-ChildItem C:\Temp -Recurse        # search sub-folders too

# Check a cmdlet's parameters and which are positional with -Syntax:
Get-Command Get-ChildItem -Syntax

Pro Tip

PowerShell supports parameter abbreviation: type only enough letters to be unambiguous. -Re works for -Recurse and -Pa for -Path — but spell them out in saved scripts so a future reader (or a new parameter that makes -Re ambiguous) never trips you up.

4. Aliases

An alias is a short nickname for a full cmdlet name. PowerShell ships with familiar ones so people coming from other shells feel at home: ls and dir both run Get-ChildItem, cd runs Set-Location, cat runs Get-Content. They're great for fast typing at the prompt. Use Get-Alias to see what any alias really points to.

# An alias is a short nickname for a full cmdlet name.
# 'ls' is just an alias for Get-ChildItem — they run the same code.

Get-Alias ls          # show what 'ls' points to

# Resolve several at once. The left side is what you type;
# the right side is the real cmdlet PowerShell actually runs:
'ls', 'cd', 'cat', 'rm' | ForEach-Object {
    $real = (Get-Alias $_).Definition
    "{0,-3} -> {1}" -f $_, $real
}

Your turn again — two blanks. Prove to yourself that an alias and its cmdlet are the same thing.

# 🎯 YOUR TURN — replace each ___ then run it.
# Goal: prove that an alias and its cmdlet are the same thing.

# 1) Find out which cmdlet 'gci' is an alias for
$target = (Get-Alias ___).Definition     # 👉 the alias, written as gci

# 2) Print it in a sentence
Write-Output "gci really runs: $___"      # 👉 the variable you made, target

# ✅ Expected output:
# gci really runs: Get-ChildItem

Putting It Together: a Mini System Report

Here's a small but real script that uses the three Get- cmdlets you'll reach for most — Get-Process, Get-Service, and Get-ChildItem — with the discovery and parameter skills from this lesson. You understand every line now.

# === A tiny system report using the three "Get-" cmdlets you'll use most ===

# 1) The 3 processes using the most memory (WS = working set, in bytes)
Get-Process |
    Sort-Object WS -Descending |
    Select-Object -First 3 Name, @{ Name = 'MB'; Expression = { [int]($_.WS / 1MB) } }

# 2) How many services are currently running
$running = (Get-Service | Where-Object Status -eq 'Running').Count
Write-Output "Running services: $running"

# 3) How many items are in the current folder
Write-Output "Items here: $((Get-ChildItem).Count)"

Each cmdlet emits objects, not text — which is why you can Sort-Object WS and Select-Object Name. 1MB is a built-in PowerShell unit (1,048,576), so dividing bytes by it gives megabytes.

Common Errors (and the fix)

📋 Quick Reference — Common Verbs

VerbMeansExample cmdlet
GetRetrieve / viewGet-Process
SetChange a valueSet-Location
NewCreateNew-Item
RemoveDeleteRemove-Item
StartBegin / launchStart-Service
StopEnd / haltStop-Process
Find / WhereSearch / filterWhere-Object

Mini-Challenge: What can I do to a Service?

No blanks this time — just a brief and an outline to keep you on track. Build it, run it, and check your output against the example in the comments. Discovering "what cmdlets exist for X" is something you'll do constantly in real work.

# 🎯 MINI-CHALLENGE: "What can I do to a Service?"
# No code is filled in — just an outline. Build it and check the output.
#
# 1. Use Get-Command to find every cmdlet whose NOUN is Service.
# 2. Keep only cmdlets (not functions): -CommandType Cmdlet.
# 3. Print just their Name property, sorted alphabetically.
# 4. BONUS: count them and print "Service cmdlets: N".
#
# ✅ Example output:
#    Get-Service
#    New-Service
#    Restart-Service
#    Resume-Service
#    Set-Service
#    Start-Service
#    Stop-Service
#    Suspend-Service
#    Service cmdlets: 8

# your code here

🎉 Lesson Complete

Practice quiz

In the cmdlet name Get-Service, which part is the verb?

  • Get
  • Service
  • The dash
  • Neither

Answer: Get. The verb is the action (Get); the noun is the thing acted on (Service).

Which cmdlet lists all the approved PowerShell verbs?

  • Get-Noun
  • List-Verbs
  • Get-Verb
  • Show-Verb

Answer: Get-Verb. Get-Verb prints the approved verbs like Get, Set, New, and Remove.

How would you find every cmdlet whose noun is Service?

  • Get-Command -Noun Service
  • Find-Service -All
  • Get-Service -List
  • Search-Noun Service

Answer: Get-Command -Noun Service. Get-Command -Noun Service finds all cmdlets that act on services.

What is a switch parameter like -Recurse?

  • A parameter needing a number
  • An on/off flag with no value
  • An alias
  • A positional value

Answer: An on/off flag with no value. A switch is a true/false flag; its presence alone turns the feature on.

Which command shows whether a parameter is positional?

  • Get-Member
  • Get-Help -Full
  • Get-Command <name> -Syntax
  • Get-Alias

Answer: Get-Command <name> -Syntax. Get-Command <name> -Syntax shows positional parameters as [[-Name] <type>].

What does the alias ls run?

  • Set-Location
  • Get-Content
  • Remove-Item
  • Get-ChildItem

Answer: Get-ChildItem. ls is an alias for Get-ChildItem, which lists items in a location.

Which cmdlet does the alias cd map to?

  • Set-Location
  • Get-Location
  • Move-Item
  • Push-Location

Answer: Set-Location. cd is an alias for Set-Location, which changes the current directory.

For Get-ChildItem, -Path is position 0. What does that allow?

  • Skipping the value
  • Dropping the -Path name and passing the value directly
  • Recursing automatically
  • Sorting output

Answer: Dropping the -Path name and passing the value directly. A positional parameter lets you omit its name: Get-ChildItem C:\Temp equals Get-ChildItem -Path C:\Temp.

Why should saved scripts spell out full cmdlet names instead of aliases?

  • Aliases run slower
  • Aliases are not always portable or guaranteed
  • Aliases cause syntax errors
  • Aliases are deprecated

Answer: Aliases are not always portable or guaranteed. Aliases can be reassigned or differ between systems, so full names are safer in scripts.

Which cmdlet shows what an object's properties and methods are?

  • Get-Command
  • Get-Help
  • Get-Property
  • Get-Member

Answer: Get-Member. Get-Member inspects an object and lists its properties and methods.

Continue this course

Frequently asked questions

How do I find a cmdlet if I don't know its name?

Use Get-Command. Filter by verb (Get-Command -Verb Get) or by noun (Get-Command -Noun Service) to narrow it down. Because every cmdlet is named Verb-Noun, you can usually guess the verb (Get to view, Set to change, New to create, Remove to delete) and then let Get-Command -Noun fill in the rest. Never guess a full name and hope — discover it.

What is the difference between a named and a positional parameter?

A named parameter is spelled out, like -Path C:\Temp, and order doesn't matter. A positional parameter relies on its position instead: -Path is position 0 for Get-ChildItem, so Get-ChildItem C:\Temp is the same as Get-ChildItem -Path C:\Temp. Run Get-Command <name> -Syntax to see which parameters are positional — they appear in [[-Name] <type>] (double brackets).

Are aliases like ls and cd safe to use in scripts?

Use them when typing interactively, but spell out the full cmdlet in scripts you save or share. Aliases can be reassigned, and some (like ls or cat) are not the same on every system or in PowerShell vs the old console — so a script that relies on them can break elsewhere. Get-ChildItem always means Get-ChildItem; ls might not.

What is a switch parameter?

A switch is a true/false flag that takes no value — its mere presence turns the feature on. -Recurse on Get-ChildItem is a switch: include it and PowerShell searches sub-folders; leave it off and it doesn't. You don't write -Recurse $true, just -Recurse.

Get-Member, Get-Help, Get-Command — when do I use which?

Get-Command finds cmdlets (what can I run?). Get-Help explains a cmdlet and, with -Examples, shows copy-paste usage (how do I run it?). Get-Member inspects the objects a cmdlet returns and lists their properties and methods (what's inside the result, so I know what I can sort or filter on?).