Equal to and not equal to

The -eq (equal to) and -ne (not equal to) operators perform exact (and, by default, case insensitive) comparisons. In the example below, the following returns true:

1 -eq 1 
'string' -eq 'string' 
[char]'a' -eq 'A' 
$true -eq 1 
$false -eq 0 

Similarly, -ne (not equal) will return true for each of the following:

20 -ne 100 
'this' -ne 'that' 
$false -ne 'false' 

The last example compares $false, the Boolean, with a string containing the word false. PowerShell will attempt to convert the word, but as the word is not an empty string, the result will be true.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.239.46