In VBScript, the If...Then...End If statement was somewhat straightforward. There were several things to be aware of:
The If and the Then statements must be on the same line.
The If...Then...End If statement must conclude with End If.
End If is two words, not one.
The VBScript If...Then...End If statement is shown in the DemoIf.vbs script:
a = 5 If a = 5 Then WScript.Echo "a equals 5" End If
In the Windows PowerShell version of the If...Then...End If statement, there is no Then keyword, nor is there an End If statement. The PowerShell If statement is easier to type. This simplicity, however, comes with a bit of complexity. The condition that is evaluated in the If statement is positioned between a set of parentheses. ...