Automation

 View Only
  • 1.  Wait-Task - The operation has timed out

    Posted Jun 19, 2017 05:19 PM

    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


  • 2.  RE: Wait-Task - The operation has timed out
    Best Answer

    Posted Jun 19, 2017 07:18 PM

    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)