VMware Cloud Community
ePoy
Enthusiast
Enthusiast
Jump to solution

Wait-Task - The operation has timed out

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

TaskStart TimeFinal TimeTime ElapsedStatus
Wait-task14:29:4614:49:4600:20:00Error
Fetch Content of a Library Item14:29:4614:30:0000:00:14Sucess
Deploy OVF package from Content Library to Resource Pool14:29:4615:01:2000:31:34Sucess
Deploy OVF Template14:30:1315:01:1900:31:06Sucess
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos