Category: 2. Conditional Statements
-
Switch Statement
When you need to check the multiple conditions in PowerShell, we must use the Switch statement. This statement in PowerShell is equivalent to the series of ‘If‘ statements, but it is simple to use. This statement lists each condition and the code of block associated with each condition. If a condition is ‘True‘, then the…
-
Else-if Statement
This type of statement is also known as ‘Else-if‘ ladder. It is useful when you want to check more than one condition within a code. If the condition of any ‘If‘ block is True, then the statements associated with that block are executed. If none of the conditions are True, then the statements inside default else block are executed.…
-
If-Else Statement
When we need to execute the block of statements either when the condition is true or when the condition is false, we must use the if-else statement. If the condition, which is a Boolean expression evaluates to True, then the statements inside the ‘if‘ body will be executed. And if the condition evaluates to false, then the…
-
If Statement
When we need to execute the block of statements only when the specified condition is true, use an If statement. This statement consists of a Boolean or logical expression followed by one or more statements. If the condition, which is a Boolean expression evaluates to True, then the statements inside the If statement will be executed. And if the…