Hyper-V start time delay

hi,

is it possible to change the hyper-v start time delay over powershell script?
I’m not really good in powershell, here’s my script:

$selectvm = get-vm | where {$_.Name -match “AP”} | Start-VM
$selectvm

how can I add here a delay, or can I change the value in the configuration over powershell ?

thanks :slight_smile:

Not sure about changing the configuration with PowerShell, but you can simply use Start-Sleep to add a delay:

## assign variables
[string]$vm_host = "localhost"
[string]$filter_text = "AP"
[int]$delay_time = 30

## collect & filter VM names
$virtual_machine = Get-VM | Where { $_.Name -match "$filter_text" }

## pause & then start VM
Start-Sleep -Seconds $delay_time
Start-VM -VM $virtual_machine -ComputerName $vm_host

Change $delay_time as necessary. Also, with the -ComputerName parameter you can use Start-VM from a normal workstation to start a VM on a remote system (such as a HyperV server).

thanks for your script, works “where” for all VMs with the $filter_text

means when I have 3 VMs?

and delay-time is in minutes or seconds?

 

thanks

Where the name of the VM is “AP” The sleep question is pretty easy to answer if you look at the code…

Start-Sleep -Seconds $delay_time