From c4b96a03ab4f083a22ad2eeeceef0b1f85b2d96b Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Fri, 7 Mar 2025 04:28:14 -0700 Subject: [PATCH] Add Scripts/Powershell/Hyper-V/Delete Locked VHDX File.md --- Scripts/Powershell/Hyper-V/Delete Locked VHDX File.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Scripts/Powershell/Hyper-V/Delete Locked VHDX File.md diff --git a/Scripts/Powershell/Hyper-V/Delete Locked VHDX File.md b/Scripts/Powershell/Hyper-V/Delete Locked VHDX File.md new file mode 100644 index 0000000..3d8732e --- /dev/null +++ b/Scripts/Powershell/Hyper-V/Delete Locked VHDX File.md @@ -0,0 +1,9 @@ +**Purpose**: +You may find that you cannot delete a VHDX file for a virtual machine you removed from Hyper-V and/or Hyper-V Failover Cluster, and either cannot afford to, or do not want to reboot your virtualization host(s) to unlock the file locked by `SYSTEM`. + +Run the following commands to unlock the file and delete it: + +```powershell +Dismount-VHD -Path "C:\Path\To\Disk.vhdx" -ErrorAction SilentlyContinue +Remove-Item -Path "C:\Path\To\Disk.vhdx" -Force +``` \ No newline at end of file