VMware PowerCLI

The Best User Interface for your VMware Datacenter!

Operation is not valid due to the current state of the object

Many cmdlets are sometimes returning this error message:

Operation is not valid due to the current state of the object

This problem has been discussed and a workaround has been found here :

https://serverfault.com/questions/654415/powercli-move-vm-returns-failure-but-vm-still-moves

However, instead of a workaround with more code, it would be better to fix this erratic behavior.

  • Luc FULLENWARTH
  • Jul 25 2019
  • Attach files
  • Brad Calvert commented
    27 Sep 00:39

    I  definitely have this problem, and at scale. Trying to perform some shared-nothing migrations of hundreds or ultimately thousands of VMs.  Sometimes the PowerShell environments in to a state where this happens to every VM.  The only solution is to close PowerShell and re-open, because even disconnecting and reconnecting from vCenter and re-starting the script does not help.  Even then it is only a matter of time before it happens again.  The main issue obviously being when the failure occurs, the script may queue dozens or hundreds of VMs up for moves in vCenter.