Skip to content

Instantly share code, notes, and snippets.

@Sambardo
Created February 28, 2018 19:25
Show Gist options
  • Save Sambardo/5c89c6bfebffe5c03a432f10bd3d5064 to your computer and use it in GitHub Desktop.
Save Sambardo/5c89c6bfebffe5c03a432f10bd3d5064 to your computer and use it in GitHub Desktop.
continue works instead of break with the loop feature
$nums = 1..15
Switch($nums)
{
{$_ -lt 5} {write-host "$_ is less than 5!" -ForegroundColor Magenta;continue}
{$_ -lt 10} {write-host "$_ is less than 10!" -ForegroundColor green;continue}
{$_ -lt 15} {write-host "$_ is less than 15!" -ForegroundColor cyan;continue}
default {write-host "$_ is greater than or equal to 15" -ForegroundColor yellow}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment