if … else … Statement Syntax

if(Boolean_expression) {
   // Executes when the Boolean expression is true
}else {
   // Executes when the Boolean expression is false
}
CODE

 

Examples

$x = 30

if($x -le 20){
   write-host("This is if statement")
}else {
   write-host("This is else statement")
}
CODE

Output: This is else statement