Converting VBScript's Eval Function

Definition: Evaluates an expression and returns the result.

Eval

OK, we’re not sure how often you need to evaluate an expression (such as a mathematical equation) and simply know whether that expression is true or false. If you do need to do this, however, you can do so simply by using the -eq comparison operator. For example, this command evaluates the expression 2 + 2 = 45 and then stores the evaluation (true or false) in the variable $a:

$a = 2 + 2 -eq 45

When you run this command and then echo back the value of $a you should get the following:

False

Return to the VBScript to Windows PowerShell home page