
Powershell – if statement
in powershell we have the option to test for a particular condition.
we can set it with the if statement
here’s the syntax for it –
if (<value> operator <value>){<code to execute if true>}
1 |
if(1+1 -eq 2) {Write-Host bla!} |
elseif (<value> operator <value>){<code to execute if true>} else{<code to execute if not true>}
1 2 3 4 5 |
$x =1 $y =3 if($x+$y -eq 2) {Write-Host bla!} elseif ($x+$y -ne 2) {Write-Host bla!bla!} |
Note that the elseif and else parts are optional in an if statement.
lets create a game with an easy if statement script fun game.
(Visited 1,370 times, 1 visits today)