VMware Cloud Community
iinfi
Contributor
Contributor

wait-task does not work when tasks it is waiting for are in wait mode

When I run the below commands in a loop and 15-20 VMs start getting created in each iteration, I see a number of VM creation tasks waiting for resources or in "Invoking callbacks" state. 

$task = New-VM -Name "$VMname" -Template $vmtemplate -Datastore $datastoreName -ResourcePool $vcentercluster -OSCustomizationSpec

wait-task $task

Wait-Task : Operation is not valid due to the current state of the object.

At this point wait-task command fails. with Operation is not valid due to the current state of the object. error

is there a solution to this?

vcenter 6.0, powercli 6.3 r1

0 Kudos
1 Reply
LucD
Leadership
Leadership

I suspect this might be the same issue as described in 6.  Re: Problem with Wait-Task


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos