If ... Else in PowerShell

if … else … Statement Syntax

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

 

Examples

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

Output: This is else statement