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