Skip to main content
Skip table of contents

new--If ... Else in PowerShell

if … else … Statement Syntax

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

 

Examples

CODE
$x = 30

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

Output: This is else statement

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.