PowerShell – Equal Operators

Equal Operators:

The equal operators return a value of TRUE if its identical or return a value of FALSE if it is not identical. The entire pattern must match an entire value. By default, all comparison operators are case-insensitive. To make a comparison operator case-sensitive, precede the operator name with a “c”. For example, the case-sensitive version of -eq is -ceq. To make the case-insensitivity explicit, precede the operator with an “i”

Operators  Description
-eq equals
-ne not equals
-gt greater than
-ge greater than or equal
-lt less than
-le less than or equal

 

Example:

$userName = 'Rakshu'
$userName -eq 'rakshu'

$userName = 'Aadharsh'
$userName -ne 'rakshu'

$number1 = 100
$number1 -gt 50

$userName = 100
$userName -le 50

OUTPUT:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.