Attach a VHDX file in Disk Management with Action then Attach VHD or mount it with PowerShell. Test-VHD checks whether the virtual disk is usable and returns True or False. No Microsoft tool repairs a damaged VHDX so a backup copy is the safe restore path. Mount with the ReadOnly parameter when you only need files.
You double click a VHDX file and Windows reports an error or you need files from an old virtual machine disk. Test the file first and then attach it.
Steps follow Microsoft pages on managing virtual hard disks and Test-VHD and Mount-DiskImage. PowerShell samples are not executed on a test machine.
What are VHD and VHDX Files?
Microsoft describes VHD files as disk image files that behave like physical disks and serve mainly Hyper-V virtual machines. Disk Management handles both .vhd and .vhdx and recommends .vhdx.
How do You Test a VHDX File?
Test-VHD -Path "C:\VHDs\data.vhdx"
Test-VHD tests a virtual hard disk for problems that would make it unusable and returns a Boolean. Microsoft does not list the exact checks. False means you should restore from a backup copy.
Test-VHD belongs to the Hyper-V PowerShell module so install Hyper-V management tools first.
How do You Attach a VHDX File in Disk Management?
- Open Disk Management as Administrator. Your account needs Backup Operators or Administrators membership.
- Select Action then Attach VHD.
- Browse to the .vhdx file and select OK.
- Select OK again to finish.
Blue disk icon means attached and available. Gray means detached. Detaching with Detach VHD does not delete the file or its data.
How do You Mount a VHDX With PowerShell?
Mount-DiskImage -ImagePath "C:\VHDs\data.vhdx" -Access ReadOnly -PassThru
| Parameter | Purpose |
|---|---|
| ImagePath | Full path to the VHD or VHDX file |
| Access ReadOnly | Mounts so files cannot change. Default permits changes |
| NoDriveLetter | Mounts without a letter |
| PassThru | Returns an object for the mounted image |
Mounting needs administrator rights. When the file is already in use Windows reports that another process uses it. Detach it first.
Related guides: GPT protective partitions and Linux KVM virtual machines.
Frequently Asked Questions
How do I Open a VHDX File in Windows?
Use Disk Management with Action then Attach VHD or use Mount-DiskImage in PowerShell.
Which Command Tests a VHDX File?
Test-VHD from the Hyper-V PowerShell module.
Does Detach VHD Delete My Data?
No. Microsoft states detaching does not delete the file or its data.
Can I Mount a VHDX as Read Only?
Yes. Add the Access ReadOnly parameter to Mount-DiskImage.
Is VHDX Better Than VHD?
Microsoft recommends the .vhdx format in Disk Management.
Key Takeaways
- VHDX files act like physical disks for virtual machines.
- Test-VHD returns True or False.
- Disk Management attaches files through the Attach VHD command.
- Mount-DiskImage has a ReadOnly option.
- Restore from a backup copy when the file fails the test.
Sources and References
Steps follow Microsoft pages.
- Manage virtual hard disks in Disk Management (Microsoft Learn) learn.microsoft.com
- Test-VHD (Microsoft Learn) learn.microsoft.com
- Mount-DiskImage (Microsoft Learn) learn.microsoft.com