Powershell - Comparison Operators Examples



The following scripts demonstrates the comparison operators.

> $a = 10
 
> $b = 20
 
> $a -eq $b
 False 
 
> $a -ne $b
 True
 
> $b -gt $a
 True
 
> $b -ge $a
 True
 
> $b -lt $a
 False
 
> $b -le $a
 False
 
> $a = "mahesh"
 
> $b = "suresh"
 
> $a -like '*ahe*'
 True
 
> $a -notLike '*ahe*'
 True
 
> $b -match '[h$]'
 True
 
> $b -notMatch '[h$]'
 False
 
> $a = 'abc'
 
> $b = 'abc'
 
> $b -contains $a
 True
 
> $b -notContains $a
 False
powershell_operators.htm
Advertisements