powershell - -match several $vars in if statement -
I have this, which does not work:
$ var1 = "6.0 6001 "$ var2 =" 6.1.7001 "$ var3 =" 6.2.8074 "$ var4 =" 6.3.8074 "if ($ var1 -mail" 6.1? "-or" 6.2.? "-or" 6.3. "" } {Write-host "1"} and {write-host "2"}
No problem, 1 is returned
thanks
Thanks
Run this code:
"6.2.?" -or "6.3.?") {Write-host "1"} and {write-host "2"}
this will also return 1 regardless of .
Change your status to:
if ($ v Ar1-mail "6.1 ??" or $ var1-match "6.2 ??" -or $ var1-match "6.3.?")
or better than:
if ($ var1 -match "6. [1-3].?")
Comments
Post a Comment