Change the default start and stop actions for all VMs in a cluster

Change the configuration of all VMs in a cluster with PowerShell

John Savill

November 7, 2016

1 Min Read
Change the default start and stop actions for all VMs in a cluster

Q. How can I change the default start and stop actions for all VMs in a cluster?

A. The code below will find all VMs in a cluster and if the Start action is not Nothing or the Stop is not ShutDown then it will set accordingly:

$VMs = Get-ClusterGroup | ? { $_.GroupType –eq “VirtualMachine” } | Get-VMForeach ($VM in $VMs){    if(($vm.AutomaticStartAction -ne "Nothing") -or ($vm.AutomaticStopAction -ne "ShutDown"))    {        $VM | ft name,automaticstartaction,automaticstopaction        Set-VM -Name $VM.VMName -ComputerName $VM.ComputerName -AutomaticStartAction Nothing -AutomaticStopAction ShutDown    }}

 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like