首页 > 解决方案 > 以 JSON 格式转义双引号 - powershell,azure cli

问题描述

请我尝试将 html 字符串作为值从 azure cli 传递给下面的 powershell 函数“set-content”,但我认为我没有正确转义双引号。value 参数只接受字符串,不知何故,它不会在目标机器上用双引号执行。我收到以下错误。请帮忙!

az vm extension set --name CustomScriptExtension --vm-name MyWindowsVM -g TestsandRG --publisher Microsoft.Compute --settings '{"commandToExecute": "powershell set-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value \"<html><body><h2>Welcome to Azure! My name is $($env:computername) .<\/h2><\/body><\/html>\""}'

在此处输入图像描述

标签: jsonazurepowershellshell

解决方案


推荐阅读