Set auto-start on all VMs in a VMware cluster with PowerCLI

I want to be able to set all VMs in a cluster to auto-start when the host starts.

Related tags: VMware

Credit: Original Poster

This sets the policy only for VMs that are currently powered on.
Replace the things in <> with your information.

Connect-VIServer <virtual center>
$vms = Get-Cluster <cluster> | Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"};
foreach ($vm in $vms) {
        Get-VMStartPolicy -VM $vm | Set-VMStartPolicy -StartAction PowerOn
}

Rating: 3

Propose a different solution...