Author Posts

March 8, 2016 at 6:48 pm

To test a variable's value, you would always use "-eq" right? You would never use "=", right? I believe that "=" in PowerShell 4 is always an assignment operator.

March 9, 2016 at 12:05 am

In all versions of PowerShell that is the case. You can use "=" in an if statement and it doesn't generate an error. Instead it will do the assignment and the 'if' result will always be $true.

March 9, 2016 at 2:54 am

= has always been the assignment operator in PowerShell and
-eq has always been the equality comparison operator

for more information on operators see the following help files
about_Arithmetic_Operators
about_Assignment_Operators
about_Comparison_Operators
about_Logical_Operators
about_Operators
about_Type_Operators