Lesson 1 of 8
Your First Script
Write and run your first .ps1 script, and learn the main idea behind PowerShell: commands pass objects, not just text.
PowerShell cmdlets (pronounced "command-lets") follow a Verb-Noun naming convention: Get-, -Item, Remove-File. They return objects with properties, not raw text. This is the main difference from .
# Write to the console
Write-Host "Hello, World!"
Write-Output "Hello from Write-Output"
# The difference:
# Write-Host: goes directly to console, can't be captured
# Write-Output: goes to the pipeline, can be captured and redirected
# Variables start with $
$name = "Alice"
$age = 30
Write-Host "Name: $name, Age: $age"
# String interpolation (double quotes only)
Write-Host "Hello, $name!"
Write-Host 'No interpolation: $name' # single quotes = literal
# Expressions in strings
Write-Host "In 10 years: $($age + 10)"
# Multiple output methods
Write-Host "Normal output"
Write-Warning "This is a warning"
Write-Error "This is an error"
Write-Verbose "This only shows with -Verbose"# Save as hello.ps1 and run in PowerShell:
# .hello.ps1
# Or run interactively:
pwshFinished reading?Mark it done to track your progress.
Tip: use the ← and → keys to move between lessons.