control
$size = 10
if ($size -gt 100) {
"big"
} elseif ($size -gt 4) {
"small"
} else {
"tiny"
}
Operators use dashes: -eq, -ne, -gt, -lt, -ge, -le
That reads oddly at first
After a week it reads like English
switch
switch ($food) {
"pizza" { "pie" }
"salad" { "green" }
default { "meal" }
}
No fall through
Each case is a script block
Use switch when one value drives several exact matches
foreach
foreach ($item in $items) {
$item
}
Works on any collection
Also available as a pipeline filter with ForEach-Object
Next
Functions in 06 functions
Test this in your lab first
Posted