Compacting the virtual hard disk files can make their size significantly smaller, depending on how much white space they have.
The older (or more used) the drive, the better your chances are for massive space gain.
1. Open an elevated PowerShell window (Win + X keys, then press A).
2. Mount the VMD or VHDX files as read-only. This is important to do, otherwise the new command might fail. Then use the Optimize-VHD cmdlet (even with vhdx files) and dismount the file when finished.
# Mount temporarily the Example.vhdx file as read-only Mount-VHD -Path "D:\VMs\Virtual Hard Disks\Example.vhdx" -ReadOnly # Compact the virtual drive Optimize-VHD -Path "D:\VMs\Virtual Hard Disks\Example.vhdx" -Mode Full # Dismount the vhdx file Dismount-VHD -Path "D:\VMs\Virtual Hard Disks\Example.vhdx"
are you serious? says
you need hyper-v modules to be installed to use those comandlets and THAT what you forgot to mention