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 ๐Ÿ™‚