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