Reading Time: < 1 minute

There are many times where we need to massively do operations on Azure VM’s, in this post we would talk how we can Start, Stop, and Restart VM’s via Azure Portal or Azure PowerShell.

 

Start, Stop VM’s via Azure Portal

Start, Stop VM’s via Azure Cloud Shell

Please check below the Azure PowerShell scripts to Start, Stop, and Restart massive Virtual Machines.

#Start Azure VMs

$ResourceGroupName = “MyVMRG”

Get-AzVM -ResourceGroupName $ResourceGroupName | Select Name | ForEach-Object {

Start-AzVM -ResourceGroupName $ResourceGroupName -Name $_.Name

}


#Stop Azure VMs

Get-AzVM -ResourceGroupName $ResourceGroupName | Select Name | ForEach-Object {

Stop-AzVM -ResourceGroupName $ResourceGroupName -Name $_.Name

}


#Restart Azure VMs

Get-AzVM -ResourceGroupName $ResourceGroupName | Select Name | ForEach-Object {

Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $_.Name

}

 

Useful Links

Share This