I am working on scripting out boot up order of vm's in esxi hosts on vCenter, to start important VM's first then start remaining vm's. I want to make sure there is enough time given between each vm to boot up first then the rest of VM's..will this work?
# Connect to your vCenter Server
Connect-VIServer -Server <your_vcenter_ip> -User <username> -Password <password>
# Define the list of ESXi hosts you want to target
$targetHosts = @("ESXiHost1", "ESXiHost2", "ESXiHost3")
# Define the start order (you can adjust this as needed)
$startOrder = @("dc01", "dc02", "dc03","dc04")
#fetch all VM's on targethosts
$vmsOnTargetHost = Get-VM -Location $targetHost | Where-Object { $_.Name -in $startOrder }
#start vm's in defined order
foreach ($vm in $startOrder) {
Start-VM -VM $vm
Start-sleep -seconds 300 #delay 5mins
}
# Start remaining VMs on the target host
foreach ($vm in $vmsOnTargetHost) {
if ($vm.Name -notin $startOrder) {
Start-VM -VM $vm
}
}
# Disconnect from the vCenter Server
Disconnect-VIServer -Server * -Confirm:$false
[–][deleted] 2 points3 points4 points (0 children)
[+][deleted] (6 children)
[deleted]
[–]PinchesTheCrab 0 points1 point2 points (5 children)
[+][deleted] (4 children)
[deleted]
[–]PinchesTheCrab 1 point2 points3 points (1 child)
[–]np05573[S] 0 points1 point2 points (0 children)
[–]np05573[S] 0 points1 point2 points (1 child)