Switch Statement Flashcards
1
Q
Format of a basic switch statement
A
$a = 3
switch ($a) { 1 {"The color is red."} 2 {"The color is blue."} 3 {"The color is green."} default {"The color could not be determined."} }
2
Q
Add in a * to the $variable
A
$a = “d14151”
switch -wildcard ($a) { "a*" {"The color is red."} "b*" {"The color is blue."} "c*" {"The color is green."} "d*" {"The color is yellow."} default {"The color could not be determined."} }
3
Q
Find the version of Windows
A
get-wmiObject win32_operatingSystem | Select version