Files
docs/scripts/powershell/hyper-v/delete-locked-vhdx-file.md
Nicole Rappe 59909dd12a
All checks were successful
Automatic Documentation Deployment / Sync Docs to https://kb.bunny-lab.io (push) Successful in 6s
revert 51cdd1fdb6
revert Fixed Formatting of Files
2026-04-26 17:22:05 -06:00

15 lines
506 B
Markdown

---
tags:
- PowerShell
- Scripting
---
**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
```