How to Compact a Dynamic VHD with Diskpart
Compacting a expandable/dynamic VHD was a mystery for me until I found those easy steps. You don't need any Hyper-V roles to make those steps. Some other products use the VHD standard, so that only show me how good is implanted the VHD standard when built-in tool easily manage the format. (need-work tag added, if someone got some en-US screenshot to change mine)
What to do
Open a command prompt
diskpart
select vdisk file="d:\store\vdisk.vhd"
attach vdisk readonly
compact vdisk
detach vdisk
exit
Result
Before: (8.2GIG)
After: (7.3GIG)
Optional step
Run sdelete tool from Microsoft in the VM before compacting the VHD. (sdelete -c)