if i use the command sequence:
$objTask = New-VM -Name $hostname -ResourcePool $objCluster -ContentLibraryItem $objContentLibrary -Location $objFolder -Datastore $objDatastoreCluster -RunAsync
write-host "Deploy OVF Template: Starting Job..."
Wait-Task $objTask
After some time the error is returned:
Wait-Task : 19/06/2017 14:05:49 Wait-Task 19/06/2017 13:54:45 Wait-Task The operation has timed out
At line:1 char:1
+ Wait-Task $objTask
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Wait-Task], ViError
+ FullyQualifiedErrorId : VICore_VMServiceImpl_DeployFromLibraryItem_Error,VMware.VimAutomation.ViCore.Cmdlets.Commands.WaitTask
Even giving this error I realized that in vcenter there are still two tasks: Deploy OVF package from Content Library to Resource Pool and then the Deploy OVF template
This two tasks are executed with sucess and vm was created even with the timeout error.
Note: The template has 25GB
Task | Start Time | Final Time | Time Elapsed | Status |
---|---|---|---|---|
Wait-task | 14:29:46 | 14:49:46 | 00:20:00 | Error |
Fetch Content of a Library Item | 14:29:46 | 14:30:00 | 00:00:14 | Sucess |
Deploy OVF package from Content Library to Resource Pool | 14:29:46 | 15:01:20 | 00:31:34 | Sucess |
Deploy OVF Template | 14:30:13 | 15:01:19 | 00:31:06 | Sucess |
Did you already try using a Get-Task in a loop?
You could for example check the status of the Task every 10 seconds.
Something like this
do{
sleep 10
$task = Get-Task -Id $taskId
}
until($task.Done)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you already try using a Get-Task in a loop?
You could for example check the status of the Task every 10 seconds.
Something like this
do{
sleep 10
$task = Get-Task -Id $taskId
}
until($task.Done)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference