February 2019
Intermediate to advanced
626 pages
15h 51m
English
Switch allows expressions (a ScriptBlock) to be used in place of a simpler condition. The result of the expression should be an explicit true or false, or an implicit Boolean, for example:
switch (Get-Date) { { $_ -is [DateTime] } { Write-Host 'This is a DateTime type' }
{ $_.Year -ge 2017 } { Write-Host 'It is 2017 or later' }
}
Read now
Unlock full access