Loading
0x10Lesson 2 of 17

Discover commands and help

Find any command with Get-Command, learn it with Get-Help, and master parameters and aliases.

22 min 7-question quiz 2 code exercises
By the end of this lesson you can
  • Find commands by verb, noun or wildcard with Get-Command
  • Read help and examples with Get-Help
  • Use named, positional and switch parameters, and look up aliases

PowerShell ships with thousands of commands, and nobody memorizes them. Instead, you learn three discovery commands and find everything else yourself:

CommandAnswers
Get-CommandWhich commands exist? (Get-Command -Noun Item, Get-Command *service*)
Get-HelpHow do I use this one? (Get-Help Get-ChildItem -Examples)
Get-MemberWhat’s inside the objects it returns? (next lesson)

Run Update-Help once (as administrator on Windows) to download the full help files. Get-Help Sort-Object -Online opens the web page instead.

discover.ps1
1Get-Command -Verb Get -Noun Date, Random | ForEach-Object Name
2(Get-Command Sort-Object).CommandType
3(Get-Alias -Name gci).Definition
4Get-Alias -Definition Get-ChildItem | ForEach-Object Name | Sort-Object
Output
Get-Date
Get-Random
Cmdlet
Get-ChildItem
dir
gci
ls

Get-Alias -Definition works backwards: which aliases point at this command? (Exactly which aliases exist depends on your system - on Linux and macOS, ls runs the real ls program instead of Get-ChildItem.)

Approved verbs

The verb part isn’t free-form: PowerShell has a list of approved verbs (Get-Verb shows them), each with a meaning - Get reads, Set changes, New creates, Remove deletes, Start/Stop control something running, Test returns true or false, Invoke runs an action. That consistency is why guessing works: if there’s a New-Item, there’s probably a Remove-Item.

When you write your own functions later, pick an approved verb too. PowerShell warns about unapproved ones when you load them in a module.

Try it

Approved or not?

Would PowerShell accept these function names without complaining? Sort them by whether the verb is on the approved list.

0 of 8 sortedScore 0/0
  • “Get-Dragon”

  • “Fetch-Dragon”

  • “Remove-Enclosure”

  • “Delete-Enclosure”

  • “New-FeedingLog”

  • “Make-FeedingLog”

  • “Test-Temperature”

  • “Check-Temperature”

Parameters: named, positional and switches

  • Named: Get-ChildItem -Path C:\Dragons - clearest; order doesn’t matter.
  • Positional: Get-ChildItem C:\Dragons - some parameters can be given by position. Get-Help Get-ChildItem -Parameter Path shows Position? 0.
  • Switches: -Recurse, -Force, -Descending - present means on, absent means off.
  • Common parameters work on every cmdlet: -Verbose, -ErrorAction, -WhatIf and friends. You’ll use them later.

Most parameters accept several values separated by commas: Get-Command -Noun Date, Random.

parameters.ps1
Get-Date -Year 2026 -Month 12 -Day 25 -Format 'dddd, d MMMM yyyy'
Get-Date -Format 'yyyy-MM-dd' -Year 2027 -Month 1 -Day 1
'ember', 'Skyla', 'glim' | Sort-Object -Descending
Output
Friday, 25 December 2026
2027-01-01
Skyla
glim
ember

Key takeaways

  • Get-Command finds commands, Get-Help explains them (-Examples is gold), Get-Member shows their objects.

  • Approved verbs make names predictable: Get, Set, New, Remove, Test, Start, Stop...

  • Parameters can be named, positional or switches; values can be comma-separated lists.

  • Aliases are shortcuts for the prompt; Get-Alias tells you what they stand for.

Lesson quiz

7 questions · pass with 5 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: write PowerShell scripts

Write a script in the editor and run it for real against sample input, which is piped into your script as $input. Scripts run on PowerShell 6.2 through Try It Online (tio.run), a free public service, so these exercises avoid PowerShell 7-only syntax; your script and test input are sent there.

Exercise 1

Alias detective

+25 XP

Each line of the input is an alias. For each one print alias -> Command using Get-Alias. The test input arrives in $input, one string per line, which the starter already loops over.

gci -> Get-ChildItem
cd -> Set-Location
  • Four aliases
  • Pipeline aliases
script.ps1
Loading editor…

Lessons teach PowerShell 7; your script runs on PowerShell 6.2 via Try It Online (tio.run), a free public service, so stick to syntax that works there. Test input is piped into your script as $input. Your script and test input are sent to that service.

Exercise 2

Hatching calendar

+25 XP

Three eggs are due. Use Get-Date with -Year, -Month, -Day and -Format to print each due date as dddd yyyy-MM-dd (the weekday, then the date):

  • Ember’s egg: 14 February 2027
  • Glim’s egg: 31 October 2026
  • Pebble’s egg: 1 January 2027

Print Name: <formatted date> on each line.

  • Three eggs
script.ps1
Loading editor…

Lessons teach PowerShell 7; your script runs on PowerShell 6.2 via Try It Online (tio.run), a free public service, so stick to syntax that works there. Test input is piped into your script as $input. Your script and test input are sent to that service.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Did you like the lesson? 😆👍
Consider a donation to support our work: