PowerShell script to set startup delay on virtual machines in Hyper-V

Last weekend I wanted to automate setting a startup delay on virtual machines on my Hyper-V host.
After searching in SCVMM, I was unable to find that option… so I started scripting with PowerShell and this is what I came up with.

To set a startup delay at 15 seconds for all VMs on a host
$VM1 = get-vm | ? {$_.hostname -like “Servername*”}  | ? {$_.name -like “VDI*”}
$VM1 | set-vm -delaystart 15

To set a startup delay of 15 seconds for all VMs which name starts with VDI
$VM1 = get-vm | ? {$_.hostname -like “Servername*”}  | ? {$_.name -like “VDI*”}
$VM1 | set-vm -delaystart 15

To set a startup delay of 15 seconds for all VM’s which name starts with VDI or XD
$VM1 = get-vm | ? {$_.hostname -like “Servername*”}  | ? {$_.name -like “VDI*” -or $_.name -like “XD*” }
$VM1 | set-vm -delaystart 15

Leave a Reply

Your email address will not be published. Required fields are marked *