Force removal of virtual machine from HYPER-V cluster

This is a field experience I occurred few days back. Customer having HYPER-V cluster which consist of 4 nodes connected to two CSV volumes. One of the VM hosted in the cluster having a problem of not booting properly. It’s been in the saved state. Looking at VMM console I can see the same VM name visible 3 times! and each vm hosted in different HYPER-V host. Tried to delete the VM from the VMM console and received the following error,

failed to delete configuration: The process cannot access the file because it is being used by another process. (0x80070020) (Virtual machine ID 9AF7EF4C-48EE-43C2-ADE7-E2D4D255B6F9) (Unknown error (0x8006)) “ <Please note VM specific details has been removed>

Tried to log into each hyper-v host VM manager separately and remove the VM but ended with the similar error. Further inspection revealed all duplicate VM names all tried to bind into the same VHD file and the config file in the CSV volume. The problem is all 3 hyper-v hosts holding to the files and cannot be deleted. It’s very clear only way to delete them is by force (Time to use the Jedi power force 🙂 )

From the VMM console you can open the PS (Yes the ultimate Power Shell) and type the following command,

$VM = Get-VM -Name <VM Name>
Remove-VM -VM $VM –Force

After that you can refresh the VMM console and see the troublesome VM has been disappeared.

Note: Prior to any of these task as a habit I make sure VM has been backup 🙂

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s