How to Completely Delete a Hyper-V Virtual Machine in Windows 8, 8.1, and Server 2012
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.
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
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.
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.
4. In the elevated PowerShell, type the command below, and press Enter. (see screenshot below)
Code:
Get-VM "[COLOR=#ff0000][B]VM Name[/B][/COLOR]" | %{ Stop-VM -VM $_ -Force; Remove-VM -vm $_ -Force ; Remove-Item -Path $_.Path -Recurse -Force}
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}
For example:
Get-VM "8.1 Update Enterprise" | %{ Stop-VM -VM $_ -Force; Remove-VM -vm $_ -Force ; Remove-Item -Path $_.Path -Recurse -Force}
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)
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)
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.
8. When finished, you can close PowerShell if you like.
That's it,
Shawn
Attachments
Last edited by a moderator: