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

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-VM
Foreach ($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
    }
}

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish