DaveWentzel.com All Things Data
Branching and Looping Constructs
The following screenshot gives some examples. Note there is no THEN and no END IF. The ELSE is optional. ELSEIF is used for secondary evaluations.
Unlike IF which shortcircuits after the first true condition, switch will continue evaluating and will run every block that evaluates to true. You can append BREAK to your code to override this behavior.
$a=somethingif($a -eq 1) break;if($a -eq 2)(continue)#this line is not reached unless $a==1
do/while loop is very similar but ensures the loop is executed at least once.
#a block of statements goes here
Foreach ($i in Get-Childitem c:\windows)