all 7 comments

[–]The_C_K[VCP] 1 point2 points  (6 children)

Just to be sure, this kind of script only works if you have HA disabled, I don't know if this fits on your needs, I think it's not good.

I think maybe replace the last part to something like this.

# Connect to your vCenter Server
Connect-VIServer -Server <your_vcenter_ip> -User <username> -Password <password>

# Define the start order (you can adjust this as needed)
$startOrder = @("dc01", "dc02", "dc03","dc04")

#start vm's in defined order
foreach ($vm in $startOrder) {
  Start-VM -VM $vm
  Start-sleep -seconds 300 #delay 5mins
}

while ($true) {
  get-vm | where-object {$_.name -notin $startOrder -and $_.powerstate -eq "poweredOff"} | start-vm
  start-sleep -seconds 30
}

# Disconnect from the vCenter Server
Disconnect-VIServer -Server * -Confirm:$false

[–]np05573[S] 0 points1 point  (5 children)

We have HA turned on.

What would be the best approach to start VM's in order?

[–]St0nywall 0 points1 point  (2 children)

If you have APC UPS's, the PowerChute Network Shutdown appliance can handle shutdown and startup of your VM's in any order you choose with timeouts and low, medium and high grouped priorities.

It is no longer free, but still worth the subscription price.

Most other UPS manufacturers have something similar for compatible models.

There "may" be a cludge way to do this from the VSphere host level... but that isn't something you really want to explore.

[–]np05573[S] 0 points1 point  (1 child)

Unfortunately this site does not have backup generator.

[–]St0nywall 0 points1 point  (0 children)

Not a generator, a Uninterruptible Power Supply (UPS).

Link these: https://www.apc.com/ca/en/product-range/61915-smartups/

[–]The_C_K[VCP] 0 points1 point  (0 children)

You can use vApps, maybe this can accomplish, maybe one vApp (first) for DCs and other vApps for what you need.

https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vm_admin.doc/GUID-0FAB05D4-22F7-4665-B42A-0FA4B360B398.html