Invoke-AzVMRunCommand for powershell removes caret character
Description
invoke-azcommand removes caret character . I tried to call invoke-azcommand to run a powershell script but my script receives parameter with deleted caret character.
$password="test^123456"
Invoke-AzVMRunCommand -ResourceGroupName $rg -VMName $vm -CommandId 'RunPowerShellScript' -ScriptPath './test.ps1' -Parameter @{"password"=$password}
in my script I print out the value of the parameter which is "test123456"
Issue script & Debug output
HTTP Method:
POST
Absolute Uri:
https://management.azure.com/subscriptions/000000000000000/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1/runCommand?api
-version=2020-12-01
Headers:
x-ms-client-request-id : 00000000000000000000
accept-language : en-US
Body:
{
"commandId": "RunPowerShellScript",
"script": [
"[cmdletbinding(SupportsShouldProcess=$true)]",
" param(",
" [parameter(Mandatory=$true)][String]$password)",
" write-host \" password is $password\""
],
"parameters": [
{
"name": "password",
"value": "test^123456"
}
]
}
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
Accepted
Body:
{
"value": [
{
"code": "ComponentStatus/StdOut/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"message": " password is test123456"
},
{
"code": "ComponentStatus/StdErr/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"message": ""
}
]
}
Environment data
Name Value
---- -----
PSVersion 5.1.19041.1682
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1682
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
Script 2.3.0 Az.Accounts
Script 4.13.0 Az.Compute
Script 3.4.4 Az.KeyVault
Error output
No response
Thank you for your feedback. This has been routed to the support team for assistance.
@rezarms We are looking into it and get back to you for any additional information.
@rezarms I am able to reproduce this and looks like issue at service end. I am checking internally on this issue and get back to you.
It seems other special characters would cause different issue. For example < character would fail script call.
@rezarms This seems to be a limitation on command prompt on VM and the product team is working to provide a fix for the caret character. I will update you as soon as it is available in production. Thanks.
A similar behavior happens here with the "&" in a paremeter string. This causes that the parameter is empty all at once.
It is really a strange behavior. Is there any feedback on this at some point?
My environment:
Windows 11
Script 2.13.1 Az.Accounts
Script 5.7.1 Az.Compute
PSVersion 7.3.8
PSEdition Core