Introduction
Operators help us check if things are equal, bigger, or smaller, and make decisions based on true or false answers.
if (<condition>) { # code to run if condition is true } else { # code to run if condition is false }
if ($a -eq 5) { Write-Output "a is 5" }
if ($age -ge 18 -and $age -lt 65) { Write-Output "Adult" }
if ($name -ne "Admin") { Write-Output "User is not Admin" }
$score = 85 if ($score -ge 90) { Write-Output "Grade: A" } elseif ($score -ge 80) { Write-Output "Grade: B" } else { Write-Output "Grade: C or below" }
$x = 5
$y = 10
if ($x -lt 10 -and $y -gt 5) { 'True' } else { 'False' }
if ($a -eq 5 -or $b = 10) { 'Yes' } else { 'No' }Pass the test and this pattern moves unknown