VMware Cloud Community
hack3rcon
Enthusiast
Enthusiast

How to solve "Orphaned" VM?

Hello,

I removed a VM from ESXi host but in "vCenter Server" in showed me "Orphaned". How can I solve it?

VM-1.png

VM-2.png

Thanks.

Reply
0 Kudos
7 Replies
a_p_
Leadership
Leadership

Did you try to remove teh VM from the inventory in vCenter?

Any error messages/warning when doing this?


André

Reply
0 Kudos
NathanosBlightc
Commander
Commander

Hi

Until the ESXi is under the management of host, you must do every operation by executing from vCenter tasks. Because you didn't do like this, it's possible that vCenter Server considers the object is not removed and doesn't know really what is going on ( because you did it by ESXi itself), so the vCenter considers the VM as an orphaned object. If you don't have an enable option to remove that orphaned VM by GUI management of vCenter server (through any vSphere Client), you can choose the following ways:

1. By PowerCLI

Connect-VIServer vCenter_Server

$allVMs=Get-VM

foreach ($vm in $allVMs)

{

if ($vm.ExtensionData.Runtime.ConnectionState -eq "orphaned") {$vm.name}

}

2. Remove it by connecting directly to vCenter database:

If your database is a SQL Server you can do it by management console of SQL and query for your object and remove it from the database. but if you have VCSA, the database is the vPostgreSQL. If you want to connect to this type of database I explain it on this post:  Connect and Manage VCSA Database (PostgreSQL). Then you can connect to the database with an application like PgAdmin.

Please mark my comment as the Correct Answer if this solution resolved your problem
Reply
0 Kudos
tayfundeger
Hot Shot
Hot Shot

You experience this problem if you connect to an ESXi managed by vCenter Server with root and delete the virtual machine. If you have deleted the virtual machine, you can use the "remove from inventory" button to remove orphaned vm.

--
Blog: https://www.tayfundeger.com
Twitter: https://www.twitter.com/tayfundeger

vBlogger, vExpert, Cisco Champions

Please, if this solution helped your problem, "Helpful" if it solves your problem "Correct Answer" to mark.
Reply
0 Kudos
SahanVMTN
Contributor
Contributor

Try to perform operations from the vCenter as much as possible when an ESXi host is being managed by a vCenter as you can minimize getting these kind of issues.

Here is the steps from an orphaned VM which I managed to remove from vCenter:

Login to vSphere web client (Adobe Flex ) > Go to Virtual Machines view > Select the Orphaned VM > Right click on it > Hover on "All Virtual Infrastructure Actions"  > Select "Remove from Inventory"

pastedImage_0.png

Thanks and regards,

Sahan

Reply
0 Kudos
Maio312
Contributor
Contributor

remove from the inventory

nishant
Reply
0 Kudos
hack3rcon
Enthusiast
Enthusiast

This "PowerCLI" command removing Orphaned VMs or just list them?

Reply
0 Kudos
NathanosBlightc
Commander
Commander

This one just list them (orphaned VMs) I told it to use if you don't have an option for "remove from inventory" in vSphere client.

Remove-VM Power-CLI let you let you remove them.

Please mark my comment as the Correct Answer if this solution resolved your problem
Reply
0 Kudos