How to forcefully remove a Virtual Machine from the SCVMM admin console

Published Feb 14 2019 09:09 PM 2,236 Views
First published on TECHNET on Apr 29, 2009


My buddy Jonathan Jordan recently came across an interesting issue and wrote up a great solution, and since he’s out today I thought I’d take the liberty of posting it.  If you ever find yourself in a position where you tried to remove a VM but it ended up being stuck in a state of limbo then this one’s for you:

========

Issue: A VM has been removed from SCVMM but still appears in the VMM Admin Console. The VM may have been removed in Hyper-V, SCVMM, or Cluster Administrator. When the VM is right clicked on there are two choices: Repair and Delete. Neither work.

Environment:
Windows 2003 with SCVMM 2007
Windows 2008 with SCVMM 2008

Resolution: If after attempting to remove the VM through normal means the machine name is still present, perform these steps:

> Method 1: Locate the .XML file for the machine and delete it.
- On the host that the VM ran on (or hosts if you are unsure which one), at a command prompt:
Type the drive letter to change to such as C: and hit enter, then...
dir *.xml /s | find /i "vm name"
- Replacing "vm name" with the name of the VM, this will search a volume for the .XML file that describes the VM
- Move the .XML file to a location that SCVMM does not use for hosted VMs or Library files
- Refresh SCVMM Admin Console

> Method 2: Force removal of VM with PowerShell.  If Method 1 did not work, follow the steps below then refresh the SCVMM Admin Console:

- In the SCVMM Admin Console click the 'PowerShell' button. Type 'A' for 'Always' if prompted by security
- Test PowerShell (this will just list information so that you will know that PowerShell is working properly):
Get-VMMServer -ComputerName localhost
- This should just list out some VMM info

- Remove VM: Replace "VM Name" with the name of the VM as it appears in SCVMM
$VM = Get-VM -Name "VM Name"
Remove-VM -VM $VM -Force

Note: If the virtual machine still exists as an .XML file as mentioned in Method 1, refresher will repopulate the VM as being present

%3CLINGO-SUB%20id%3D%22lingo-sub-340669%22%20slang%3D%22en-US%22%3EHow%20to%20forcefully%20remove%20a%20Virtual%20Machine%20from%20the%20SCVMM%20admin%20console%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-340669%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20Apr%2029%2C%202009%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Fscvmm%2Fdefault.aspx%22%20mce_href%3D%22http%3A%2F%2Ftechnet.microsoft.com%2Fen-us%2Fscvmm%2Fdefault.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20%3C%2FA%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3C%2FP%3EMy%20buddy%20Jonathan%20Jordan%20recently%20came%20across%20an%20interesting%20issue%20and%20wrote%20up%20a%20great%20solution%2C%20and%20since%20he%E2%80%99s%20out%20today%20I%20thought%20I%E2%80%99d%20take%20the%20liberty%20of%20posting%20it.%26nbsp%3B%20If%20you%20ever%20find%20yourself%20in%20a%20position%20where%20you%20tried%20to%20remove%20a%20VM%20but%20it%20ended%20up%20being%20stuck%20in%20a%20state%20of%20limbo%20then%20this%20one%E2%80%99s%20for%20you%3A%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3D%3D%3D%3D%3D%3D%3D%3D%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3EIssue%3A%20%3C%2FB%3E%20A%20VM%20has%20been%20removed%20from%20SCVMM%20but%20still%20appears%20in%20the%20VMM%20Admin%20Console.%20The%20VM%20may%20have%20been%20removed%20in%20Hyper-V%2C%20SCVMM%2C%20or%20Cluster%20Administrator.%20When%20the%20VM%20is%20right%20clicked%20on%20there%20are%20two%20choices%3A%20Repair%20and%20Delete.%20Neither%20work.%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3EEnvironment%3A%20%3CBR%20%2F%3E%20%3C%2FB%3E%20Windows%202003%20with%20SCVMM%202007%20%3CBR%20%2F%3E%20Windows%202008%20with%20SCVMM%202008%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3EResolution%3A%20%3C%2FB%3E%20If%20after%20attempting%20to%20remove%20the%20VM%20through%20normal%20means%20the%20machine%20name%20is%20still%20present%2C%20perform%20these%20steps%3A%3C%2FP%3E%0A%20%20%3CP%3E%26gt%3B%20Method%201%3A%20Locate%20the%20.XML%20file%20for%20the%20machine%20and%20delete%20it.%20%3CBR%20%2F%3E%20-%20On%20the%20host%20that%20the%20VM%20ran%20on%20(or%20hosts%20if%20you%20are%20unsure%20which%20one)%2C%20at%20a%20command%20prompt%3A%20%3CBR%20%2F%3E%20Type%20the%20drive%20letter%20to%20change%20to%20such%20as%20C%3A%20and%20hit%20enter%2C%20then...%20%3CBR%20%2F%3E%20dir%20*.xml%20%2Fs%20%7C%20find%20%2Fi%20%22vm%20name%22%20%3CBR%20%2F%3E%20-%20Replacing%20%22vm%20name%22%20with%20the%20name%20of%20the%20VM%2C%20this%20will%20search%20a%20volume%20for%20the%20.XML%20file%20that%20describes%20the%20VM%20%3CBR%20%2F%3E%20-%20Move%20the%20.XML%20file%20to%20a%20location%20that%20SCVMM%20does%20not%20use%20for%20hosted%20VMs%20or%20Library%20files%20%3CBR%20%2F%3E%20-%20Refresh%20SCVMM%20Admin%20Console%3C%2FP%3E%0A%20%20%3CP%3E%26gt%3B%20Method%202%3A%20Force%20removal%20of%20VM%20with%20PowerShell.%26nbsp%3B%20If%20Method%201%20did%20not%20work%2C%20follow%20the%20steps%20below%20then%20refresh%20the%20SCVMM%20Admin%20Console%3A%3C%2FP%3E%0A%20%20%3CP%3E-%20In%20the%20SCVMM%20Admin%20Console%20click%20the%20'PowerShell'%20button.%20Type%20'A'%20for%20'Always'%20if%20prompted%20by%20security%20%3CBR%20%2F%3E%20-%20Test%20PowerShell%20(this%20will%20just%20list%20information%20so%20that%20you%20will%20know%20that%20PowerShell%20is%20working%20properly)%3A%20%3CBR%20%2F%3E%20Get-VMMServer%20-ComputerName%20localhost%20%3CBR%20%2F%3E%20-%20This%20should%20just%20list%20out%20some%20VMM%20info%3C%2FP%3E%0A%20%20%3CP%3E-%20Remove%20VM%3A%20Replace%20%22VM%20Name%22%20with%20the%20name%20of%20the%20VM%20as%20it%20appears%20in%20SCVMM%20%3CBR%20%2F%3E%20%24VM%20%3D%20Get-VM%20-Name%20%22VM%20Name%22%20%3CBR%20%2F%3E%20Remove-VM%20-VM%20%24VM%20-Force%3C%2FP%3E%0A%20%20%3CP%3E%3CI%3E%20Note%3A%20If%20the%20virtual%20machine%20still%20exists%20as%20an%20.XML%20file%20as%20mentioned%20in%20Method%201%2C%20refresher%20will%20repopulate%20the%20VM%20as%20being%20present%20%3C%2FI%3E%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-340669%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TECHNET%20on%20Apr%2029%2C%202009%20My%20buddy%20Jonathan%20Jordan%20recently%20came%20across%20an%20interesting%20issue%20and%20wrote%20up%20a%20great%20solution%2C%20and%20since%20he%E2%80%99s%20out%20today%20I%20thought%20I%E2%80%99d%20take%20the%20liberty%20of%20posting%20it.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-340669%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESystem%20Center%20Virtual%20Machine%20Manager%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Mar 11 2019 08:10 AM
Updated by: