Windows 8 and 8.1 Forums


Hyper-V Virtual Machine - Completely Delete in Windows 8

  1. #1
    Hyper-V Virtual Machine - Completely Delete in Windows 8

    Hyper-V Virtual Machine - Completely Delete in Windows 8
    How to Completely Delete a Hyper-V Virtual Machine in Windows 8, 8.1, and Server 2012
    Published by Brink is offline
    02 Jul 2014
    Default Hyper-V Virtual Machine - Completely Delete in Windows 8

    Published by


    Brink's Avatar
    Administrator

    Join Date: Jul 2009
    Posts: 22,022

    How to Completely Delete a Hyper-V Virtual Machine in Windows 8, 8.1, and Server 2012


    information   Information
    The Hyper-V technology provides an environment that you can use to create and manage virtual machines and their resources. Each virtual machine is an isolated, virtualized computer system that is capable of running its own operating system. This allows you to run multiple operating systems at the same time on the same physical computer.

    When you delete a virtual machine (VM) in Hyper-V Manager, it will only delete the VM's checkpoints, delete VM's configuration and ID files, and remove the VM from Hyper-V Manager. It will not delete the VM's virtual hard disks and folders though.

    This tutorial will show you how to completely delete all traces of a Hyper-V virtual machine all at once from a host Windows 8, 8.1, and Server 2012 PC.

    You must be signed in as an administrator to be able to do the steps in this tutorial.

    Note   Note
    What will be deleted:

    • VM will be removed from Hyper-V Manager
    • All checkpoints created for the VM in Snapshots folder.
    • All virtual hard disks in Virtual Hard Disks folder for the VM.
    • Configuration files and ID in Virtual Machines folder for the VM.
    • All other folders for the VM. For example, the folders the above folders are saved in.


    EXAMPLE: Hyper-V Manager
    NOTE: The virtual machine names are listed under Virtual Machines at the top in the middle pane.


    Click image for larger version




    Here's How:

    1. Shut down and turn off any virtual machine you want to delete.

    2. Open an elevated PowerShell.

    3. In the elevated PowerShell, type get-vm, and press Enter to see a list of all Hyper-V virtual machine (VM) names on the host PC. Make note of the VM's name (ex: 8.1 Update Enterprise) you want to completely delete. (see screenshot below)

    NOTE: If you like you can also see the name of the VM in Hyper-V Manager.

    Click image for larger version

    4. In the elevated PowerShell, type the command below, and press Enter. (see screenshot below)

    Code:
    Get-VM "VM Name" | %{ Stop-VM -VM $_ -Force; Remove-VM -vm $_ -Force ; Remove-Item -Path $_.Path -Recurse -Force}
    Note   Note
    Substitute VM Name in the command above with the actual name of the VM from step 2 above.

    For example:

    Get-VM "8.1 Update Enterprise" | %{ Stop-VM -VM $_ -Force; Remove-VM -vm $_ -Force ; Remove-Item -Path $_.Path -Recurse -Force}


    Click image for larger version

    5. If the Hyper-V VM is currently running, then click/tap on Exit when prompted, and go to step 7 below. (see screenshot below)

    Name:  PowerShell_delete-vm-3.png
Views: 30934
Size:  13.9 KB

    6. If the Hyper-V VM is not currently running, then you will see the WARNING: The Virtual machine is already in the specified state message just to let you know. There's nothing that needs to be done. (see screenshot below)

    Click image for larger version

    7. When you see the PS C:\Windows\system32> prompt return, the VM has finished being completely deleted. (see screenshots below)

    NOTE: This could take a little while to finish.

    Click image for larger version
    Click image for larger version

    8. When finished, you can close PowerShell if you like.


    That's it,
    Shawn


  2. #1


    Does this tutorial and the two included related tutorials apply to win10?

      My System SpecsSystem Spec

  3. #2


    Posts : 22,022
    64-bit Windows 10


    Hello trbodden,

    Yes, you can use them in Windows 10 as well.
      My System SpecsSystem Spec

  4. #3


    Hi, thanks, I will try this in the future, but too late for a bunch of them...

    I already deleted the VM from Hyper-v manually, now I am stuck with a bunch of old files.
    I could go in and clean them manually, but the names are not always easily matching.
    Would there be a way to find the useless files and delete them via a script?

    Thanks,
    Alex
      My System SpecsSystem Spec

  5. #4


    Posts : 22,022
    64-bit Windows 10


    Hello Alex, and welcome to Eight Forums.

    Not that I'm aware of after removing the VM name in the Hyper-V Manager.

    If you know where you set to store the virtual machine, then you should be able to just delete the VM's folder to completely remove it.
      My System SpecsSystem Spec

  6. #5


    Thanks for the quick response.
    My issue is that few "manager" (including me) placed there folder here and there.
    I deleted a few unused VM.
    Now I need to guest where is what to clean it up.

    I'll keep everything as-is for know, but sooner that later I'll have to find a way to clean this up to release space!
      My System SpecsSystem Spec

  7. #6


    Posts : 22,022
    64-bit Windows 10


    In that case, you could see if doing a search with "*.vhd" and "*.vhdx" in File Explorer for the virtual hard disks files may help find their location.
      My System SpecsSystem Spec

  8. #7


    Posts : 4
    win


    I used mentioned script.... I didn't saw any wm manager, so I tried to restart vmms - it is unable to strart - I don't know why. All symlinks are deleted - adding them didn't help. I don't know what to do...
      My System SpecsSystem Spec

  9. #8


    Posts : 22,022
    64-bit Windows 10


    Hello mato, and welcome to Eight Forums.

    Please provide more details about what you are wanting to do.

    If you used this tutorial, it will permanently delete any VMs you used it on.
      My System SpecsSystem Spec

  10. #9


    Posts : 4
    win


    I just wanted to delete one specific vm, as described...When I ran mentioned command (with vm name replaced) hyper-v manager just shows 2 my wm's (more than 10 should be displayed). I found, that symlinks of all vm's were deleted, so I recreated them and tried to restart vmms. No luck there, vmms stopped and I am unable to start it. Now my wms are running, but I can't manage them. I am worried, that restart of hypervisor will cause situation - wms not running and me unable to start them....
      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
Hyper-V Virtual Machine - Completely Delete in Windows 8

Similar Threads
Thread Forum
Hyper-V Create Linux Virtual Machine in Windows 8
How to Create a Linux Hyper-V Virtual Machine in Windows 8 Although best when running Windows guests, Windows 8 built-in Microsoft Hyper-V can also be used to run Linux guests. Officially Hyper-V only supports SUSE and Red Hat enterprise server distributions but with a few simple tricks any...
Tutorials
Error creating virtual machine (Client Hyper-V, Win 8 Pro)
I'm using an AlienWare M14 machine. I tried to create a virtual machine locally using Client Hyper-V on Windows 8 Pro, but it still doesn't work (took me a lot of time). I added the Hyper-V features in "Turn windows feature on or off", and all of the requirements to run Hyper-V are fulfilled (SLAT,...
Virtualization
Hyper-V Virtual Machine - Export and Import in Windows 8
How to Export and Import a Hyper-V Virtual Machine in Windows 8 and 8.1 The Hyper-V technology provides an environment that you can use to create and manage virtual machines and their resources. Each virtual machine is an isolated, virtualized computer system that is capable of running its own...
Tutorials
activate windows 8.0 in virtual machine
Installed windows 8.0 pro on oracle VM VirtualBox (running 8.1 pro on host machine) and it asks me to activate windows. Okay, but it doesn't accept the product key I purchased for the host machine. what to do?
Virtualization
Install Windows 8 on a Virtual Machine?
OK, so I finally got my copy of Window 8 Pro from my school, and am wondering if I can try it out on a virtual machine? If so, which virtual software would you recommend? Thanks.
Virtualization
Windows 8 Machine Running Windows 7 Virtual Machine
Hey all. I just recently purchased a laptop with Windows 8 and wanted to set up a VM of Windows 7 on it. I have never worked with VM's before and I'm ready to get it going. Could anyone provide any help as to how to do it. Thanks!!!
Virtualization
Windows 8 Virtual Machine
I had installed windows 8 in VBOX. I could not get the sound to work. It stated no Audio detected. I uninstalled it, and reinstalled it in VMWARE. It is working fine. I tried to run it again in VBOX but the same thing, no audio drivers detected. I am running it in VMWARE and it is working great,...
Virtualization
Eight Forums Android App Eight Forums IOS App Follow us on Facebook