lundi 22 février 2021

Why is this condition being met when verifying parameters using the -notMatch condition?

I am validating parameters passed into a release pipeline with Powershell. The parameter I am passing as a pipeline variable is val1. Here is my code below:

if ("$(Value)" -notMatch "val1" -or "$(Value)" -notMatch "val2"){
  Write-Host "$(Value) must be val1 || val2"
  Write-Host "Value of param: "$(Value)""
  exit 1
}

When I print my value is states val1. Why is this condition being met? I thought perhaps it was because its case sensitive however even when I modify the condition to catch the exact case, it's still being met.

Aucun commentaire:

Enregistrer un commentaire