Add Scripts/Powershell/Hyper-V/Delete Locked VHDX File.md

This commit is contained in:
2025-03-07 04:28:14 -07:00
parent 32d6e973a8
commit c4b96a03ab

View File

@ -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
```