Unregister invalid VMs using ESXi command-line

From Notes_Wiki

Home > VMWare platform > VMWare vSphere or ESXi > Unregister invalid VMs using ESXi command-line

If a VM is deleted at vCenter when host is disconnected and same information is not synced with ESXi host properly, then VM might appear in invalid state at ESXi host. Also if VM is deleted at data-store level by deleting .vmx file but not using proper VM delete option then it might show up as invalid VM at ESXi level.

To unregister (similar to remove from inventory for vCenter) such VMs use:

  1. Login into ESXi web console (vsphere-client) and verify that invalid VM is present and that it is not getting deleted using ESXi console.
  2. SSH to ESXi host
  3. List all registered VMs using:
    vim-cmd /vmsvc/getallvms
  4. Unregister particular VM using:
    vim-cmd /vmsvc/unregister <id>
  5. Verify from ESXi web console (vsphere-client) that invalid VM is no longer listed
  6. After this if the same VM shows up in vsphere-inventory with path /volumes/vmfs/<vm-id> then wait for 5-10min. After 5-10min, "Remove from Inventory" option should come in vCenter for the corresponding VM.
  7. Note that above steps only remove the VM from vSphere or vCenter. If the VM was not deleted from datastore its disk and configuration files might still be present and need to be deleted separately.

Refer:



Home > VMWare platform > VMWare vSphere or ESXi > Unregister invalid VMs using ESXi command-line