Fix issue where tags json is wrong in PS5 (#8058)

This commit is contained in:
Vasilii Polikarpov
2023-08-09 11:50:49 +02:00
committed by GitHub
parent 4ec9fdae13
commit 6ed173f0ad

View File

@@ -288,6 +288,12 @@ Function GenerateResourcesAndImage {
}
}
$TagsJson = $Tags | ConvertTo-Json -Compress
if ($PSVersionTable.PSVersion.Major -eq 5) {
Write-Verbose "PowerShell 5 detected. Replacing double quotes with escaped double quotes in tags JSON."
$TagsJson = $TagsJson -replace '"', '\"'
}
& $packerBinary build -on-error="$($OnError)" `
-var "client_id=$($spClientId)" `
-var "client_secret=$($ServicePrincipalClientSecret)" `
@@ -298,7 +304,7 @@ Function GenerateResourcesAndImage {
-var "storage_account=$($storageAccountName)" `
-var "install_password=$($InstallPassword)" `
-var "allowed_inbound_ip_addresses=$($AgentIp)" `
-var "azure_tags=$($Tags | ConvertTo-Json -Compress)" `
-var "azure_tags=$($TagsJson)" `
$builderScriptPath
}
catch {