Skip to content
AgileLogics
4 min read

Your First Commands

Prerequisites: Installing PowerShell 7

PowerShell commands — cmdlets — are named Verb-Noun:

Write-Output "Hello, world!"
Get-Date -Year 2025 -Month 4 -Day 22 -Format "dddd, d MMMM yyyy"

Expected output

Hello, world!
Tuesday, 22 April 2025
  • Write-Output sends a value down the pipeline — at the end of the pipeline, PowerShell displays it.
  • Get-Date gets a date; its parameters (-Year, -Format) start with a dash and are followed by a value.

Try a few more on your own machine:

# illustrative
Get-Location
Get-ChildItem
Get-Process | Select-Object -First 3

Verbs are standardized

A small set of approved verbs covers almost everything:

Verb Does Example
Get retrieves something Get-Service
Set changes something Set-Location
New creates something New-Item
Remove deletes something Remove-Item
Start / Stop starts or stops Stop-Process
Test checks, returns true/false Test-Path

Get-Verb lists them all.

Case and shortcuts

  • PowerShell is not case-sensitive: get-date, Get-Date, and GET-DATE all work. The convention in scripts is Verb-Noun capitalization.
  • Aliases are short names for common commands: ls, dir, and gci all run Get-ChildItem; cd runs Set-Location. They're handy when typing, but write full names in scripts, for readability.
  • Parameter names can be shortened while they're unambiguous: -Fo for -Format.

Common mistakes

  • A space in the wrong place: Get -Date runs a command called Get.
  • Forgetting quotes around values with spaces: Write-Output Hello world passes two separate values.

Practice

Print your name on one line and your favorite food on the next with two Write-Output commands.

Show solution
Write-Output "Ada"
Write-Output "Pizza"
Ada
Pizza