I am wondering if the issue i am seeing is below
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
I am trying to use the az vm run-command invoke command but i am having issues with the credentials.
Below is the script i am trying to use. The script works if it is run from the machine itself but when invoking remotely it gets stuck in a loop and times out after 90 minutes I think. I can invoke similar scripts that do not require credentials, so I am guessing its the creds causing this.
The account being used has the correct permissions as i can run the script on the VM
Does anyone have any ideas on why it doesnt like the credentials?
$User = "TestUser"
$PWord = ConvertTo-SecureString -String "TestPassword" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
az vm run-command invoke --command-id RunPowerShellScript --resource-group MyRG --name Myserver --scripts 'param([string]$Credentials) Remove-Computer -UnjoinDomaincredential $Credentials --PassThru -Verbose -Restart -Force' --parameters "Credentials=$Credential"
I am wondering if the issue i am seeing is below
@Shane Walford
According to the example supplied here, you are missing closing and opening single quotes. Please give this a try and see if it resolves your issue.
az vm run-command invoke --command-id RunPowerShellScript --resource-group MyRG --name Myserver --scripts 'param([string]$Credentials)' 'Remove-Computer -UnjoinDomaincredential $Credentials --PassThru -Verbose -Restart -Force' --parameters "Credentials=$Credential"
Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.