Asked by:
SCVMM 2019 - ghost VMs

Question
-
Hi,
When we remove the Hyper-V replication of a VM from one server to another, we also delete the replicated VM (via HyperV manager) and associated VHDX from the destination Hyper-V host. In SCVMM, sometimes the deleted replica VM still appears as a VM for the destination Hyper-V host. What's the best way remove these VM ghosts?
Thanks
Friday, July 31, 2020 11:23 PM
All replies
-
Hi,
The best way to remove the ghost VM is by using below PowerShell cmdlet. This will remove the VM's information from SCVMM DB completely. In the next refresh, VM should not be listed.
Get-SCVirtualMachine –Name “VMNAME" | Remove-SCVirtualMachine -Force
Try this and let me know if it worked for you. Thanks.
Regards
Aayoosh Moitro
Please remember to mark the replies as answers if they help and unmark them if they provide no help. This posting is provided "AS IS" with no warranties, and confers no rights.
- Proposed as answer by Aayoosh Moitro Friday, August 7, 2020 6:15 AM
- Edited by Aayoosh Moitro Friday, August 7, 2020 8:46 AM
Saturday, August 1, 2020 2:49 PM -
If the VM is live on on the source HyperV, the Get-SCVirtualMachine | Remove-SCVirtualMachine will actually remove a live VM. How do remove from SCVMM a ghost (replica) VM without removing the live source VM?
Thanks
Wednesday, August 5, 2020 9:17 PM -
Hi,
If you use switch -Force it will not remove the vm itself but it will remove its information from the VMMDB. The same switch is already mentioned on my first post. Try it and let me know.
Regards
Aayoosh MoitroPlease remember to mark the replies as answers if they help and unmark them if they provide no help. This posting is provided "AS IS" with no warranties, and confers no rights.
Thursday, August 6, 2020 6:39 PM -
Okay, we'll try the -Force switch.
The -Force switch seems count-intuitive to how it's used in other commands, but that's what the microsoft documentation describes:
https://support.microsoft.com/en-us/help/2680205/using-the-remove-scvirtualmachine-powershell-command-in-system-center
Thanks
Thursday, August 6, 2020 8:32 PM -
Yes, it works. But if someone forgets the -Force switch, then there'll be trouble.
Is there a method to do this by editing the SCVMM database instead?
Thanks
Thursday, August 6, 2020 11:38 PM -
Hi,
There are couple of ways to remove VM's information using SQL query. Below are the details:
1. Use below link which helps to remove Stale/missing VM information from VMMDB.
2. If you want to remove a specific VM information, you can use the query mentioned in the below link: This comes from a 3rd party, so use it on your own risk.
https://www.robvit.com/system_center/vmm/delete-vm-from-vmm-database/
Always take a fresh VMMDB backup before modifying the VMM DB. Hope this helps! Thanks.
Regards
Aayoosh MoitroPlease remember to mark the replies as answers if they help and unmark them if they provide no help. This posting is provided "AS IS" with no warranties, and confers no rights.
- Proposed as answer by Aayoosh Moitro Friday, August 7, 2020 6:15 AM
Friday, August 7, 2020 6:15 AM -
Monday, August 10, 2020 12:36 PM
-
Is there a script to remove a specific/named VM from the VMM DB?
(sometimes the stale/ghost VMs don't display as "Missing")
Thanks
Monday, August 10, 2020 4:53 PM -
Yes- I had provided the link on my previous reply. Here is the link again. Thanks.
https://www.robvit.com/system_center/vmm/delete-vm-from-vmm-database/
Please remember to mark the replies as answers if they help and unmark them if they provide no help. This posting is provided "AS IS" with no warranties, and confers no rights.
Monday, August 10, 2020 5:39 PM