PSPowerShell · Lesson 1 of 8

Your First Script

PowerShell scripts have the .ps1 extension. The first thing you need to know: PowerShell works with objects, not just text. This changes everything.

PowerShell cmdlets (pronounced "command-lets") follow a Verb-Noun naming convention: Get-Process, Set-Item, Remove-File. They return objects with properties, not raw text. This is PowerShell's biggest differentiator from Bash.

PowerShell
# 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"
Bash
# Save as hello.ps1 and run in PowerShell:
# .hello.ps1

# Or run interactively:
pwsh
◆ Note
PowerShell is case-insensitive. Write-Host, write-host, and WRITE-HOST all work. By convention, use PascalCase for cmdlet names (Write-Host) and camelCase for variables ($myVariable).