How to pass a value that has ampersand (&) and possibly other characters. the following powershell script fails
$groupname = "owtest"
$tags = @()
$key="test"
$value="some=&this&that"
$tags += "$key=$value"
$creation = az pipelines variable-group create --name $groupname --variables $tags --only-show-errors
Is there a workaround to allow the ampersand embedded character?
In my test, we must use double quotes(single quotes can't work for this scenario) for value which contains &
or other characters. So if you pass variables directly to final command, it should be:
az pipelines variable-group create --name $groupname --variables test="some=&this&that" ...
And if you want to use the format above($tags += "$key=$value"
), you need to
use $value="""some=&this&that"""
instead of $value="some=&this&that"
.