How Can We Help?
Foresee all OSCustomizationSpec events
A handy way to configure the guest OS of a new VM, is to use the Guest OS Customization Spec.
But note that this customisation might take a while, and will most probably include a reboot.
The best way to wait until that customisation has been completed is to monitor for the correct events. Don’t forget to also include the possibility that the customisation might fail.
1 2 3 4 5 6 7 8 |
$vm = New-VM @sVM $now = Get-Date $eventTypes = Get-VIEvent -Entity $vm -Start $now | %{$_.GetType().Name} while($eventTypes -notcontains 'CustomizationSucceeded' -and $eventTypes -notcontains 'CustomizationFailed’){ Start-Sleep -Seconds 5 $eventTypes = Get-VIEvent -Entity $vm -Start $now | %{$_.GetType().Name} } |