Azure devops az管道嵌入的符号(&;)在传递key=value时中断

Azure devops az管道嵌入的符号(&;)在传递key=value时中断,azure-devops,powershell-4.0,azure-cli2,Azure Devops,Powershell 4.0,Azure Cli2,如何传递包含符号(&)和其他字符的值。以下powershell脚本失败 $groupname = "owtest" $tags = @() $key="test" $value="some=&this&that" $tags += "$key=$value" $creation = az pipelines variable-group create --name $groupname -

如何传递包含符号(&)和其他字符的值。以下powershell脚本失败

 $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

是否有允许使用符号和嵌入字符的解决方法?

在我的测试中,我们必须对包含
&
或其他字符的值使用双引号(单引号在这种情况下不起作用)。因此,如果将变量直接传递给final命令,则应为:

az pipelines variable-group create --name $groupname --variables test="some=&this&that" ...
如果您想使用上述格式(
$tags+=“$key=$value”
),您需要
使用
$value=“”some=&this&that”“
而不是
$value=“some=&this&that”

尝试
$value='some=&this&that'
而不是
$value=“some=&this&that”
,它会工作吗?您可以
编写主机$tags
来检查最终的“$tags”会是什么样子。这对我不适用“az pipelines variable group variable create”(az pipelines变量组变量创建)。我必须用双引号括住每个“&”,并用单引号括住整个变量,如下所述:……但如果值中有引号呢!?这太疯狂了,真的需要记录指导原则。