Managed IT Security

How To Remove Invalid VMs From ESXi Using CLI

Symptoms

  • Virtual Machines show as invalid or orphaned in vCenter Server
  • Virtual Machines show as invalid or orphaned after a VMware High Availability (VMware HA) host failure occurs
  • Virtual Machines show as invalid or orphaned after an ESX host comes out of maintenance mode
  • Virtual Machines show as invalid or orphaned after a failed DRS migration
  • Virtual Machines show as invalid or orphaned after a storage failure
  • Virtual Machines show as invalid or orphaned after the connection is lost between the vCenter Server and the host where the virtual machine resides
  • You see one or more of these errors when trying to start a virtual machine:

Could not power VM, no swap file, failed to power on VM.
VMControl error -11: No such virtual machine.
A general system error occurred. The system returned on error. Communication with the virtual machine may have been interrupted

Download Our Services Brochure

 

Possible Cause

  • A virtual machine can show up as invalid or orphaned in these situations.
  • After a vMotion or VMware DRS migration.
  • After a VMware HA host failure occurs, or after the ESX host comes out of maintenance mode.
  • A virtual machine is deleted outside of vCenter Server.
  • vCenter Server is restarted while a migration is in progress.
  • Too many virtual machines are scheduled to be relocated at the same time.
  • Attempting to delete virtual machines when an ESX/ESXi host local disk (particularly the root partition) has become full.
  • Rebooting the host within 1 hour of moving or powering on virtual machines.
  • A .vmx file contains special characters or incomplete line item entries.
  • Reload all invalid virtual machines on a single host at one time.
  • vCenter database is full.

 

Contact HEX64

 

Fix

To unregister a VM using VIM command.

Log in through SSH client (putty) and run below command.

By default SSH disable on ESXi server. Follow these steps to enable SSH or skip this if already enabled.

a.) ProcedureSelect the host, click Manage, and keep Settings selected.

b.) Click Security Profile.

c.) In the Services section, click Edit.

d.) Select SSH.

  a. To temporarily start or stop the service, click the Start or Stop button.

        b. To change the Startup policy across reboots, select Start and stop with  host and reboot the host

e.) Click OK. SSH command : vim-cmd /vmsvc/unregister <Vmid>## put VMID of the invalid VM which has to be removed.
To get VMID run this command, this command will list all

VMIDsvim-cmd vmsvc/getallvms

41 thoughts on “How To Remove Invalid VMs From ESXi Using CLI”

  1. It is the best time to make a few plans for the future and it’s time to be happy. I’ve read this submit and if I may just I want to recommend you few attention-grabbing things or advice.I wish to read even more things approximately it.

  2. Thanks for the tips. I needed the following command to display the VMID of the invalid VM:
    vim-cmd vmsvc/getallvms includeConfigNotAvailable

  3. Having read this I thought it was very enlightening. I appreciate you taking the time and effort to put this article together. I once again find myself personally spending way too much time both reading and commenting.

  4. I used to be able to find good advice from your blog articles. This is also really helpful video.

  5. this blog really help me while working for a project while setting up ESXi by using CLI. Thank you HEX64.

  6. Does your website have got a contact page? I’m having problems locating it but, I’d want to send an e-mail. I’ve got great website and i also look ahead to seeing it grow after a while.

  7. Wonderful site. Lots of useful info here. I’m sending it to some pals ans also sharing in delicious. And certainly, many thanks in your sweat!

  8. This post provides clear idea in favor of the newest people of blogging, that the truth is how you can do managing a blog.

  9. Thank you for every other excellent article. The place else may anyone get that kind of info in such an ideal way of writing? I’ve a presentation subsequent week, and I am on the search for such info.

  10. Hi my relative! I prefer to state that this post is amazing, nice written and include approximately all vital infos. I’d like to peer more posts similar to this .

  11. Way cool! Some very valid points! I appreciate you scripting this write-up in addition to the remaining website is really good.

  12. I am really inspired with your writing talents as neatly as with the layout to your weblog. Is this a paid subject or did you customize it yourself? Either way stay up the nice quality writing, it’s uncommon to look a great weblog like this one today.

  13. I just want to say I am just new to weblog and actually loved you’re website. Very likely I’m planning to bookmark your site . You certainly have fabulous article content. Thanks for sharing your web page.

  14. I think other website proprietors should take this site as a model, very clean and excellent user-friendly style and design. You are an expert in this topic!

  15. Hey there just wanted to give you a quick heads up and let you know a few of the images aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different internet browsers and both show the same results.

  16. Good day! Very nice and informative blog to know VMs from ESXi by using CLI. Very much useful content while working on ESXi.

  17. I like the helpful information you supply in your articles. I will bookmark your weblog and test again here frequently. Good luck for the next!

  18. Hey There. I found your blog using msn. This is a very well written article. I will make sure to bookmark it and come back to read more of your useful information. Thanks for the post. I definitely comeback.

  19. This was super useful. Thank you to everyone involved for creating this topic and posting a simple resolution.

Leave a Reply

Your email address will not be published. Required fields are marked *