Reply to Message

View discussion in a popup

Replying to:
Macleud
Enthusiast
Enthusiast

Hi.

I'm not sure this will help. But in my scripts I use something like this:

 

$New_Vm_Task = New-VM -ContentLibraryItem $VmTemplate -Name $VMName -ResourcePool $ResourcePool -Location $Location -StorageFormat $DiskFormat -Datastore $Datastore -RunAsync
Wait-Event -Timeout 20
$task = Get-Task -Status Running | where name -eq 'Deploy OVF template' | where {$_.ExtensionData.Info.EntityName -eq "$VMName"} 
if ($task) {
    $ts = Wait-Task -Task $task
}
elseif (!$task) {
    Wait-Event -Timeout 18
    $task = Get-Task -Status Running | where name -eq 'Deploy OVF template' | where {$_.ExtensionData.Info.EntityName -eq "$VMName"}
    $ts = Wait-Task -Task $task 
    if (!$task) {
        Wait-Task -Task $New_Vm_Task 
    }
}

 

Reply
0 Kudos