Found this piece of information while attempting to shrink the size of the vhdx that I have. Over 75% of the file is empty.

I attempted to “shrink” the vhdx through Hyper-V Management Console but it didn’t make any changes to the file.

Here are the steps I performed:

I found another article that suggests these steps

  1. Right click Powershell and Run as Administrator
  2. Mount-VHD -Path C:\path\vhdname.vhdx -ReadOnly
  3. Optimize-VHD -Path C:\path\vhdname.vhdx -Mode Quick
  4. Dismount-VHD C:\path\vhdname.vhdx

I had to run step #3 multiple times, until it wouldn’t shrink the file any more.

This did the trick for me. Took down the size of the virtual machine from 370gb to 140gb.