VMware Cloud Community
5zx555555
Contributor
Contributor

How to delete VM's from vSphere Client if they are stuck?

I have problems with couple VM. They were linked clone desktops. I could not delete them from Horizon View Administrator. All VM was stuck. Pool could not be deleted too. So i used KB1008658 http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=100865...  I have deleted VM's from database. Everything was fine. I am stuck in this KB's last article (Deleting the virtual machine from vCenter Server). VM's are powered off. In vSphere client i try to use function "delete from disk". I get message: the operation is not allowed in the current state. I can not delete machine. If i try to power it on i get message: no host is compatible with the virtual machine. How can i correctly revome those machines from vsphere client?

19 Replies
john23
Commander
Commander

VM must be registered to ESX host. can you check using command line in esx host?

A

Thanks -A Read my blogs: www.openwriteup.com
Reply
0 Kudos
OscarDavey
Hot Shot
Hot Shot

so you want to remove VM from  Vcenter inventory or want to remove with data store ?

Your Oscar

Reply
0 Kudos
SatyS
Hot Shot
Hot Shot

Please go through this

Hope this helps

-SatyS

If you find this useful,please mark the answer as correct/helpful Regards, SatyS http://myvirtuallearning.wordpress.com/
Reply
0 Kudos
5zx555555
Contributor
Contributor

I want to remove from inventory (and datastore).

Reply
0 Kudos
5zx555555
Contributor
Contributor

All my hosts are ok. And "resources" are good and alive.

Reply
0 Kudos
SatyS
Hot Shot
Hot Shot

Right-click the virtual machine in VC and select Remove from Inventory.

Right-click the virtual machine and select Delete from Disk.

For both these you need to power off the VM first.

-SatyS

If you find this useful,please mark the answer as correct/helpful Regards, SatyS http://myvirtuallearning.wordpress.com/
Reply
0 Kudos
5zx555555
Contributor
Contributor

VM's are powered off. In summary tab you can see machines state: powered off.

Reply
0 Kudos
jidhin
VMware Employee
VMware Employee

Hi,

You could probably go to below location of that particular host were the VM resides and remove the complete VM entry.

/etc/vmware/hostd/vmInventory.xml

Hope this helps.

Regards

Jidhin

If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!
admin
Immortal
Immortal

To delete an orphaned virtual machine:

  1. Open VMware Infrastructure or vSphere Client and connect to vCenter Server with a user with Administrative rights.
  2. Change the view to the VMs and Templates inventory view.
  3. On the left hand pane, right-click on vCenter Server and click New Folder....
  4. Provide any alpha-numeric name to the folder.
  5. Left-click the virtual machine and while holding the left mouse button, drag the Virtual Machine the folder created in step 3.
  6. Right-click on the folder, and click Remove.The folder and its contents are deleted.


If these steps do not resolve the issue, there may be a file lock on the virtual machine files by an ESX host. To determine if an ESX host has a lock on the virtual machine files see Identifying the ESX host that is locking the file http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&e...

If a host is maintaining a lock on the virtual machine files, connect directly to the host with the vSphere Client as root to determine the virtual machine status and try to power off and remove the virtual machine from inventory.

Heeyeol_Yu
Contributor
Contributor

Hi

I have the same problem, but I want to remove the orphaned VM via some CLI for automation purpose.

I used “vim-cmd vmsvc/destroy <VM ID>”  in ESX server, but it’s marked as “orphaned” in vCenter

Is there a way to complete remove VM via some CLI?

Thx

Reply
0 Kudos
matros
Contributor
Contributor

Do this from PowerCLI

path to powercli\Initialize-PowerCLIEnvironment.ps1

out_remove= Remove-VM VM-name -DeletePermanently -Confirm:$false

rnwolfe
Contributor
Contributor

I've been battling this for a while, and the folder approach didn't work for me because I couldn't move the orphaned VMs to new folders (I am using vSphere 6.5). For some, I just moved the other virtual machines that I didn't want to delete out of the folder and then removed it. This was a crappy solution for me because some folders had large amounts of VMs.

I ended up connecting to the vSphere server using VMware Fusion and deleting the remaining ones from there, and it worked like a charm - although a very questionable enterprise solution. Smiley Happy I expect this might work with VMware Workstation, as well.

JoelStanczyk
Contributor
Contributor

I just had to use PowerCLI, worked like a charm I might add.

  1. In PowerCLI, connect to the vCenter in question with the connect-viserver command
  2. Remove-VM -VM <VMName> -DeletePermanently -Confirm:0

You can leave off the Confirm:0 part

segaszivos
Contributor
Contributor

I deleted a VM directly from the ESXi host and it left it orphaned in vSphere. I followed the article as described here - Deleting an orphaned virtual machine when the Remove option is not available (1011468) | VMware KB

No dice. The solution was to use PowerCLI to permanently delete the VM from the vSphere environment.

Reply
0 Kudos
AveryFreeman
Enthusiast
Enthusiast

Yep, this worked for me --

I used vim-cmd to get all vms and identified the two I needed to get rid of

$ vim-cmd vmsvc/getallvms

the two that I had that were orphaned were at the very top

I edited the vmInventory.xml file

$ vi /etc/vmware/hostd/vmInventory.xml

(use dd to delete a line at a time,  :wq to exit and save, :!q to exit without saving)

I then reset these two services:

$ /etc/init.d/hostd restart

$/etc/init.d/vpxa restart

then reloaded the web UI and they were gone.  Hope this helps someone else.

ian0x0r
Contributor
Contributor

I can confirm this trick also works with workstation and vSphere 6.5. Nice tip Smiley Happy

Reply
0 Kudos
rpas2915
Contributor
Contributor

For me worked  connect to vsphere by VMware Workstation and there  option to remove was active.

AUTOZ
Enthusiast
Enthusiast

This is the way@

Reply
0 Kudos
bramwellt
Contributor
Contributor

I had the same issue. I could not remove from inventory via the flash vSphere Web Client. I could, however, log into the HTML5 version of the Web Client and had the ability. Another nail in the flash coffin.

Reply
0 Kudos