az vm run-command
CautionRun commands in VMs
az vm run-command invoke -g <rg> -n <vm> --command-id RunShellScript --scripts '<cmd>'
Executes inside the VM without SSH/RDP — the rescue path when you've locked yourself out.
Examples
az vm run-command invoke -g rg -n web01 --command-id RunShellScript --scripts 'systemctl restart sshd'Repair sshd remotely
Syntax
az vm run-command invoke -g rg -n vm --command-id RunShellScript|RunPowerShellScript --scripts cmd
Before you run it
Runs with full privileges.
Used when you see
Related commands
- aws ssm start-sessionSession Manager shell
- az vm listList Azure VMs
The same reference, with no signal at all
Every command and flow from this site, held on your device and searchable with no connection. Free to install, no ads.
Get it free on the App Store