다음을 통해 공유


Azure Compute: Start, Stop , And Restart Multiple VMs

Introduction

In this post we read how we can easily Start, Stop, or Restart massively Azure virtual machines. 
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

View

Start, Stop VM's via Azure Cloud Shell

View 

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 }