Before you begin, make sure you have the following:
PowerShell 7 is available via choco:
choco install powershell-core
brew install powershell/tap/powershell
# Ubuntu / Debian
sudo apt-get install -y powershell
Create a file called hello.ps1:
# hello.ps1 - Your first PowerShell script
param(
[string]$Name = 'World'
)
$greeting = "Hello, $Name!"
Write-Output $greeting
# Bonus: Get some system info
$info = [ordered]@{
User = $env:USERNAME ?? $env:USER
OS = $PSVersionTable.OS
PSVersion = $PSVersionTable.PSVersion
Date = Get-Date -Format 'yyyy-MM-dd'
}
[PSCustomObject]$info | Format-List
Tip: Use
pwshto launch PowerShell 7, notpowershell(which launches Windows PowerShell 5.1).
| Command | Alias | Description |
|---|---|---|
Get-ChildItem |
ls, dir |
List files and folders |
Set-Location |
cd, sl |
Change directory |
Get-Content |
cat, type |
Read file contents |
Select-Object |
select |
Pick specific properties |
Where-Object |
where, ? |
Filter pipeline objects |
Once you have PowerShell installed, check out the Markdown Feature Showcase to see what your static site generator can do.