Lesson 3 • Beginner
Cmdlets and Syntax
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.
What You'll Learn
- Read the Verb-Noun structure (Get-, Set-, New-, Remove-)
- Discover any cmdlet with Get-Command, Get-Help -Examples, and Get-Member
- Tell named, positional, and switch parameters apart
- Use aliases like ls and cd — and know when not to
- Drive the everyday cmdlets: Get-Process, Get-Service, Get-ChildItem
- Stop guessing cmdlet names and find the right one in seconds
💡 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, GroupVerb Group
---- -----
Get Common
New Common
Remove Common
Set CommonRun 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 NameName
----
Get-Service
New-Service
Restart-Service
Resume-Service
NAME
Get-Service
-------------------------- Example 1 --------------------------
Get-Service
Gets all of the services on the local computer.
Name
----
CanStop
DependentServices
DisplayNameNow 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-ProcessDebug-Process
Get-Process
Start-Process
Stop-Process
Wait-Process___ blanks, then run it in your own PowerShell or at onecompiler.com/powershell and check your output against the expected lines.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 Directory: C:\Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 15/06/2026 09:14 1024 app.log
-a--- 15/06/2026 08:02 512 errors.log
Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [-Recurse] [-Force] ...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
}CommandType Name Version Source
----------- ---- ------- ------
Alias ls -> Get-ChildItem
ls -> Get-ChildItem
cd -> Set-Location
cat -> Get-Content
rm -> Remove-ItemYour 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-ChildItemgci really runs: Get-ChildItem___ blanks, then run it in your own PowerShell or at onecompiler.com/powershell and check the output.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)"Name MB
---- --
chrome 842
Code 503
pwsh 118
Running services: 96
Items here: 7Each 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)
- "The term 'List-Files' is not recognized…" — you guessed a cmdlet name.
Listisn't an approved verb. Don't guess; runGet-Command -Noun File(or-Verb Get) and let PowerShell tell you it'sGet-ChildItem. - A script that uses
lsorcatworks on your machine but breaks elsewhere — aliases aren't portable or guaranteed. In saved scripts, always spell out the full cmdlet:Get-ChildItem,Get-Content. - "Parameter cannot be processed because the parameter name 'p' is ambiguous" — your abbreviation matched more than one parameter. Add letters until it's unique (
-Path), or just type the full name. - "Parameter set cannot be resolved using the specified named parameters" — you combined parameters from two different parameter sets (e.g.
-Nameand-DisplayNametogether). Pick one set.Get-Command <name> -Syntaxshows which parameters belong together. - "A positional parameter cannot be found that accepts argument 'X'" — you passed a value with no name to a cmdlet that has no positional slot for it. Name it explicitly, e.g.
-Filter X.
📋 Quick Reference — Common Verbs
| Verb | Means | Example cmdlet |
|---|---|---|
| Get | Retrieve / view | Get-Process |
| Set | Change a value | Set-Location |
| New | Create | New-Item |
| Remove | Delete | Remove-Item |
| Start | Begin / launch | Start-Service |
| Stop | End / halt | Stop-Process |
| Find / Where | Search / filter | Where-Object |
Frequently Asked Questions
Q: 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.
Q: 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).
Q: 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.
Q: 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.
Q: 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?).
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
- ✅ Cmdlets are named
Verb-Noun—Get-,Set-,New-,Remove- - ✅ Discover, don't guess:
Get-Command,Get-Help -Examples,Get-Member - ✅ Parameters come in named, positional, and switch forms; parameter sets can't be mixed
- ✅ Aliases like
lsandcdare fine at the prompt, full names in scripts - ✅ You can drive
Get-Process,Get-Service, andGet-ChildItem - ✅ Next lesson: Variables and Data Types — store and reuse the output of these cmdlets
Sign up for free to track which lessons you've completed and get learning reminders.