7.3 Powershell Conditions Loops Arrays Flashcards
1
Q
If Statement
A
Contains a boolean expression followed by one or more statements if(bool expression) { //Statements execute if bool expression is true }
2
Q
If Else
A
if(bool expression){ //Executes if true } else{ //Executes if false }
3
Q
If Elseif Else
A
if(Boolean_expression 1) { // Executes when the Boolean expression 1 is true }elseif(Boolean_expression 2) { // Executes when the Boolean expression 2 is true }elseif(Boolean_expression 3) { // Executes when the Boolean expression 3 is true }else { // Executes when the none of the above condition is true. }
4
Q
Switch
A
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.
5
Q
Loops
A
For Loop - Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable
ForEach Loop - Used to traverse arrays
While Loop - Repeats a statement while a condition is true
do..While Loop - Like a while loop but tests the condition at the end of the loop body
6
Q
Array
A
Arrays store collections of data or variables or objects