How to use Less Than or Equal To in PowerShell
In PowerShell, to can use the Logical operator Less than or Equal to, you have to use -le logical operator.
Example
$var = 5
If($var -le 10 && $var -gt 0)
{
Write-Host "Hello World"
}
Logical Operators List in PowerShell
Below is the list of Logical Operators List in PowerShell:
1) Equal in PowerShell
-eq
Example
If($var -eq "debug")
{
Write-Host "Hello World"
}
2) Not Equal in PowerShell
-ne
Example
If($var -ne "debug")
{
Write-Host "Hello World"
}
3) Greater Than in PowerShell
-gt
Example
If($var -gt 10)
{
Write-Host "Hello World"
}
4) Greater Than or Equal in PowerShell
-ge
Example
If($var -ge 10)
{
Write-Host "Hello World"
}
5) Less Than in PowerShell
-lt
Example
If($var -lt "debug")
{
Write-Host "Hello World"
}
5) Less Than or Equal to in PowerShell
-le
Example
If($var -le 10)
{
Write-Host "Hello World"
}
6) Not in PowerShell
! OR -not
Example
If($var -not "debug")
{
Write-Host "Hello World"
}
7) OR in PowerShell
-or
8) And in PowerShell
-and
9) Like in PowerShell
-like