VMware Cloud Community
bruins05G
Contributor
Contributor

Delay between virtual machine reboots

Hello,

Does anyone know how to specify a time delay between issuing reboots of virtual machines in a folder? I can send the restart command but don't know how to tell the script to wait 4 seconds before issuing a restart to the next virtual machine in line. I just know the -RunAsync command. Any help would be greatly appreciated.

$vmdesktops = Get-folder -Name "test" |get-vm

Restart-VM $vmdesktops -Confirm:$false -RunAsync

0 Kudos
1 Reply
LucD
Leadership
Leadership

Something like this ?

Get-folder -Name "test" | Get-Vm | %{

    Restart-VM $_ -Confirm:$false -RunAsync

    Sleep 4

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos