powershell -Or operator not working
Try
If ($User -match "administrator" -or $User -match "kahuna")
Your -or
operator doesn't tie the values of the previous operator together. You need to specify a 2nd conditional operator after -or
I believe.
Nick is right, vote up his answer. You can also use parens if that is easier to see:
If (($User -match "administrator") -or ($User -match "kahuna"))
The parens are implied and PSH sees them there anyway. With or without the parens, $User = "administrator"
would first resolve to:
If (($true) -or ($false))
which resolves to $true
.