What branching logic is available in PS?
if(test){
}
elseif(){
}
else{
}
switch($var){
test {dosomething
break}
test2 {}
default {}
}How do we create multiple statements on a single line in PS.
Use semi-colon.
$v = 1; $v2 = 2
How do we make switch work with collections?
Just use the collection in the switch test:
switch(1..5)
{
#Tests go here
}How can we make switch tests case-insensitive?
use the -caseinsensitive switch
switch -caseinsensitive(“Blah”){}
How can we make switch tests use wildcards
Use the -wildcard switch and then use wildcard characters in the switch tests:
switch -Wildcard (“Blah”){
“Bl*” {DoSomething}
“?la?” {DoSomethingElse}
}