How to shrink a VHDx file by the unallocated partition space that it contains
I have a dynamic VHDX file/virtual hard drive that contains 3 partitions and 30GB of unallocated space.
How can I shrink the VHDX file/virtual hard drive by getting rid of that unallocated space inside it?
Apparently, it is possible with a Powershell command like so:
Resize-VHD -Path '\SomePath\My-VHD-File.vhdx' -ToMinimumSize
However, this doesn't seem to work on Windows 10 Professional, as it only seems to be available on Windows Server OSes.
Resize-VHD is a Hyper-V tool cmdlet.
To install the Hyper-V cmdlets, run PowerShell as Administrator and enter:
Install-WindowsFeature -Name RSAT-Hyper-V-Tools