Unable to Delete or Interact with a Duplicate VM in vCenter Inventory
search cancel

Unable to Delete or Interact with a Duplicate VM in vCenter Inventory

book

Article ID: 406957

calendar_today

Updated On:

Products

VMware vCenter Server VMware vCenter Server 8.0

Issue/Introduction

In some cases, two virtual machines with the same name may appear in the vCenter inventory.
One of them may appear to be powered on in vCenter, but when you check the ESXi host directly, it is not.

When attempting to power off the duplicate VM from vCenter, you may receive the following error:
The object 'vim.VirtualMachine:vm-123456' has already been deleted or has not been completely created.

Environment

vCenter Server 7.0
vCenter Server 8.0

Resolution

To remove the duplicate VM from vCenter, follow these steps:

⚠️ Important: These steps involve direct database changes. Proceed only if you are confident, and always create a backup or snapshot before making modifications.

1. Backup the vCenter

  • Take an offline snapshot of the vCenter Server.

  • If you are running in Linked Mode, all vCenters in the linked group must be backed up or have an offline snapshot taken.

2. Identify the Impacted VM

  • Note down the exact name of the affected VM.

3. Stop the vpxd Service

service-control --stop vpxd

4. Connect to the vCenter Database

psql -U postgres -d VCDB

5. Find the Duplicate VM Entries

SELECT count(*), name FROM vpx_entity group by name where count(*) > 1 and type_id-=1;

You should see two different IDs for the same VM name. For example:

   id   |  name   | type_id | parent_id
--------+---------+---------+-----------
123456  | VM_NAME |       0 |    XXXXXX
954345  | VM_NAME |       0 |    XXXXXX
(2 row)

6. Identify the “Powered On” Entry

Check which VM entry has a power_state of 1 (powered on):

SELECT id, dns_name, power_state FROM vpx_vm WHERE id = 123456;

Example output:

   id   |   dns_name   | power_state
--------+--------------+-------------
123456  |    VM_NAME   |           1
(1 row)


7. Update the Power State

Change the power state from 1 (on) to 0 (off):

UPDATE vpx_vm SET power_state = 0 WHERE id = 123456;


8. Verify the Change

SELECT id, dns_name, power_state FROM vpx_vm WHERE id = 123456;

Expected output:

   id   |   dns_name   | power_state
--------+--------------+-------------
123456  |    VM_NAME   |           0
(1 row)

9. Disconnect from the Database

\q

10. Restart the vpxd Service

service-control --start vpxd


11. Remove the Orphaned VM

  • Go back to the vSphere Web Client.

  • The affected VM should now appear powered off or orphaned.

  • Right-click it and select Remove from Inventory.