How to delete orphaned VMs on VMware vCenter 6.5

Before VMware vCenter 6.5, deleting orphaned VMs was really easy. You just needed to connect with the VMware vSphere Client (the fat client) to the vCenter server, create a new folder, move the broken stuff in it, and delete the folder.

Well… on vCenter 6.5, that’s not possible anymore as you can’t connect with the vSphere Client on the vCenter server, just to the ESXi.

The only workaround for this was to use PowerCLI (version 6.5 can be downloaded from here)

After installing PowerCLI, start it from your Desktop or from the Start Menu and type:

Connect-VIServer -Server YourvCenterServer

You’ll now be prompted for credentials needed to login in vCenter.


The following command will show you all VMs registered in vCenter

Get-VM -Name *

And to delete the orphaned one(s)

Get-VM -Name YourOrphanedVMName | Remove-VM

To see all running VMs and a bunch of other info type:

Get-VM | select * | Out-GridView

When you deleted all your VMs, you should also check to see if the process left behind some crap like unused VMDKs.

Good luck!


Victor an End User Computing Consultant. You find him most of the time on Twitter (@01004753) but also on LinkedIn evangelizing new technologies and processes that can change in good, the world we live in. Victor has expertise in Server & Client Virtualization, Client Management, GPU Virtualization, HyperConvergence and Enterprise Security

Tagged with: , , ,
Posted in error, fixes, HowTo, PowerCLI, vCenter, VMware
11 comments on “How to delete orphaned VMs on VMware vCenter 6.5
  1. thank you for sharing this 🙂

  2. ROE says:

    Works at first attempt. Thank you! 🙂

  3. ctom8 says:

    Thank you ! You really help me.

  4. Randy White says:

    Great article! Took me forever to find it…Thanks!

  5. russfellows says:

    While this method works, the problem only exists in the 6-5 Flash client. Another method is to utilize the HTML5 client. When browsing to an orphaned VM, you have the option to remove from inventory, just like the old C# client. The reasoning has to do with the underlying method invoked to get the list of VM’s. These two UI’s utilize different paths and calls to display the VM’s, which is why it doesn’t work using the Flash client.

    • Victor says:

      Thanks for the comment Russ.
      I don’t recall what was the client that got me into that issue but you could be right.
      Haven’t migrated completely to the HTML5 client mostly due to lack of settings and because the interface is “too loose” (I’m one of those guys that prefer compact interfaces) 🙂

  6. Oluwasegun Kolawole says:

    What if i have multiple VMs like 150 VMs to be deleted from vCenter. What is the command ?

  7. Serge K says:

    Can you help with a command to delete multiple VMs from vcenter using VMWare PowerCLI, about 150 VMs in a text file.

    • Victor says:

      Hi Serge, try this:

      Connect-VIServer -Credential (Get-Credential)
      # All vms in vcenter
      $vms = Get-VM
      # VM names supplied by the admin
      $vmnames = Get-Content vmnames.txt
      # Array of VMs to be deleted
      $array = @()
      # Array of VMs non existent
      $array1 = @()
      # Multiple for-loop to compare the names and append in both the arrays.
      foreach ($vmname in $vmnames)
      foreach ($vm in $vms)
      if ($ -match ($vmname -replace “(OFF)”,””))
      $array += “” | select @{l=’CSV_VMName’;e={$vmname}},@{l=’VC_VMName’;e={$}}
      $array1 += Write-Host “$vmname does not exist in vcenter”

      # Delete all the Stale VMs permanently
      $array | % { Remove-VM $_.VC_VMName -DeletePermanently -Confirm:$false }

      This script is something I found on the web with a simple search. I did not had time to test it, but seems it will do the job. You’ll need to create a DeleteVMlist.ps1 and vmnames.txt in a folder, modify the with your actual vCenter hostname, then run the DeleteVMlist.ps1 from PowerCLI. You should be prompted to enter the credentials for connecting and deleting the VMs (permissions to delete VMs is required).

      Have a test with a couple of dummy VMs.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow Victor Homocea on
My Gravatar

Storage, Virtualization, Container Orchestration

Marius Sandbu

cu camera pe bord

Stuff about WindowsVirtualDesktop

Ingmar Verheij

About Citrix, Remote Desktop, Performance, Workspace, Monitoring and more...

Carl Stalhood

Filling gaps in EUC vendor documentation

Stéphane Thirion

Don't Follow the Trend

Victor Homocea

Ray Heffer

Enterprise Technologies

Elvis Apostol

Calatorind prin lumi indepartate, pictez in cuvinte, lacrimi de culori.

%d bloggers like this: