steps to reproduce
switch -range (1..10) {
(1..3) { Write-Host $_ -ForegroundColor Yellow}
(4..7) {Write-Host $_ -ForegroundColor red}
(8..10) {Write-Host $_ -ForegroundColor cyan}
}
with this switch we can use range operator
@p0W3RH311
switch (1..10) {
{$_ -in (1..3)} { Write-Host $_ -ForegroundColor Yellow}
{$_ -in (4..7)} {Write-Host $_ -ForegroundColor red}
{$_ -in (8..10)} {Write-Host $_ -ForegroundColor cyan}
}
Most helpful comment
@p0W3RH311