A: A Virtual Hard Disk (VHD) or VHDX file can be shrunk to reduce its size (or possible size, if dynamic) by using the Resize-VHD cmdlet.

However, you might hit a problem where the VHD can't be shrunk by as much as expected, even though in the case of a dynamic VHD, the actual physical size of the VHD on disk is far less than the size you are trying to resize to.

The important part isn't the VHD's size on disk but rather the size of volumes that have been created inside the VHD. You can't shrink a VHD size below the size of created volumes. This can be seen with the Get-VHD command:


PS D:\> <strong>get-vhd d:\temp\temp2tb.vhdx</strong>


Which returns the output below:

ComputerName         : SAVDALHV01<br>
Path                 : D:\temp\temp2tb.vhdx<br>
VhdFormat            : VHDX<br>VhdType              : Dynamic<br>
FileSize             : 339738624<br>
Size                 : 2199023255552<br>
<strong>MinimumSize          : 220023767552</strong><br>LogicalSectorSize    : 512<br>PhysicalSectorSize   : 4096<br>BlockSize            : 33554432<br>ParentPath           : <br>
FragmentationPercentage : 6<br>
Alignment            : 1<br>
Attached             : True<br>
DiskNumber           : 7<br>
IsDeleted            : False<br>
Number               : 7

The MinimumSize value shows the smallest size the VHD can be shrunk to. In this case, the size is 200GB because I have a 200GB volume created inside the VHD. If I shrink the size of the volume inside the VHD file (or remove it) that would reduce the size I can shrink the VHD to.