Completely remove Hyper-V Virtual Machines

Yes, I know, why not use Hyper-V console remove Virtual Machines?

Thanks for Jokelainen Jouni gave me this idea about create this script!

So as you know, when delete Virtual Machines from Hyper-V console, it left all the checkpoint hard disks and virtual hardisks behin. In a case, if you have lots of Hyper-V host, lots of Virtual Machines, it is pain in the ass to clean them up.

So I came up this simple powershell script. This script can be use only locally in a Hyper-V host, not remotely. And it need to be run as Administrator.
Inside the script, has a funtion call “Remove-MyLabVM”, you can just use the funtion if you don’t want use the powershell menu I made.

 

Just for fun, I also make a “Remove Virtual Machine” tool.

When use it locally, it need to be run as admin rights, and do not required input username and password.
When use it remotely, it can be run as normal user right, and it is need to input username and password that has admin rights for the remote Hyper-V host.
When use it remotely, it also required your firewall and winrm are configured as allowed, because it needs to run powershell remotely to another computer.

You can download it from TechNet: Download Here

One thought on “Completely remove Hyper-V Virtual Machines

  1. Jouni Jokelainen

    Thanks Sandy..i used to have billions of virtual machine leftovers from different kind of tests. Its pain to remove them because when created in a hurry, the virtual hard drives are not necessarily in same place with other machine files. Removing them manually is pain in the butt ……but not anymore πŸ˜€ πŸ˜€

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *