PowerShell Basics
Cmdlets, variables, objects with properties and methods, operators and the object pipeline.
PowerShell commands (cmdlets) are named Verb-Noun — Get-ChildItem, Import-Csv, Where-Object — and they output .NET objects. Text is still easy to produce, but filtering and sorting work on named properties, which makes scripts more readable and less fragile than text parsing.
First script
$variables need no declaration; strings in double quotes expand variables.
Strings are .NET objects: .Length, .ToUpper(), .EndsWith().
@(...) is an array, @{...} a hashtable; $boards[-1] is the last element.
Comparisons are written as words: -eq, -gt, -like (wildcards), -match (regex, groups in $Matches).
Get-ChildItem outputs file objects, so Sort-Object Name and $_.Length use real properties.
Getting around
if ($a > 5) {... } if ($a -gt 5) {... } In PowerShell > is output redirection: this writes $a into a file named 5.
How do you list the properties of the objects a command returns?
Pipe it to Get-Member, e.g. Get-ChildItem | Get-Member.