powershell - -match several $vars in if statement -



powershell - -match several $vars in if statement -

i have this, doesn't work:

$var1 = "6.0.6001" $var2 = "6.1.7001" $var3 = "6.2.8074" $var4 = "6.3.8074" if($var1 -match "6.1.?" -or "6.2.?" -or "6.3.?") { write-host "1" }else{ write-host "2" }

no matter what, 1 returned.

what should like?

thanks.

run code:

if("6.2.?" -or "6.3.?") { write-host "1" }else{ write-host "2" }

it'll homecoming 1 no matter what.

change status to:

if($var1 -match "6.1.?" -or $var1 -match "6.2.?" -or $var1 -match "6.3.?")

or better:

if($var1 -match "6.[1-3].?")

powershell if-statement match

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -