if in powershell code example
Example 1: powershell else if
$num = 9
if ($num -gt 10)
{
"$num is greater than 10"
}
else
{
"$num is NOT greater than 10"
}
Example 2: powershell if operator
if (condition1 -eq condition2) {
//statement
} else {
//statement
}
-eq Equals to
-ne Not equal to
-gt Greater than
-ge Greater than or equal to
-lt Less than
Example 3: powershell else if
if (condition) {
# Whatever
}
elseif (condition) {
# Whatever
}