April 2015
Intermediate to advanced
282 pages
6h 41m
English
The most basic and most used comparison operator is equal to (-eq). This operator is flexible in nature as it can be used for strings, integers, and objects. The -eq operator is used by calling value1 is equal to value2. When the –eq operator evaluates the statement, it will return a Boolean value of either True or False. If the expression evaluates to be True, PowerShell will continue to proceed to execute the code.
A script that shows how to use equal comparison operators would look like this:
$value1 = "PowerShell" $value2 = "PowerShell" if ($value1 –eq $value2) { Write-Host "It's Equal!" }
The output of this is shown in the following screenshot:
From the preceding example, you will see that the equal comparison ...
Read now
Unlock full access