Hi,
I have a script that moves a VM to another Cluster.
$MoveVMTask = Move-VM -vm "VMName" -Destination (Get-Cluster -name NewCluster)
Wait-Task -Task $MoveVMTask
I get a:
Wait-Task : Cannot bind parameter 'Task'. Cannot convert the "VMNAME" value of type "VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl" to type "VMware.VimAutomation.Sdk.Types.V1.Task".
How to use Wait-Task properly
Yes, that helps sometimes as well.
And no, no clue why that would happen.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The Wait-Task only works for tasks that run in the background, and that is done through the RunAsync switch.
$MoveVMTask = Move-VM -vm "VMName" -Destination (Get-Cluster -Name NewCluster) -RunAsync
Wait-Task -Task $MoveVMTask
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD
thanks for your fast reply.
I tried -RunAsync but now i get "Wait-Task : Operation is not valid due to the current state of the object."
But the VM is moving....
Something is still wrong??
If the vMotion is actually do, then it looks like an issue I have seen before.
Try this procedure Re: Eh? Move-VM Generates Error Messages, But Works Anyway!?!?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Now its working! Thank you! 🙂
"I found that closing the current powershell session and opening a new one seems to resolve the issue. Running version 6.0."
But i really do not understand why????
Yes, that helps sometimes as well.
And no, no clue why that would happen.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference