https://www.altaro.com/hyper-v/shrink-hyper-v-virtual-disk-vhd-vhdx/
PS C:\Windows\system32> Get-VHD "D:\Hyper-V\Virtual Hard Disks\Test-Restore.vhdx" ComputerName : J-M710Q-H1 Path : D:\Hyper-V\Virtual Hard Disks\Test-Restore.vhdx VhdFormat : VHDX VhdType : Dynamic FileSize : 23089643520 Size : 549755813888 MinimumSize : 50491048448 LogicalSectorSize : 512 PhysicalSectorSize : 4096 BlockSize : 33554432 ParentPath : DiskIdentifier : FB1B192A-3FD6-4E2C-AE5F-20395BDA8252 FragmentationPercentage : 0 Alignment : 1 Attached : False DiskNumber : IsPMEMCompatible : False AddressAbstractionType : None Number : PS C:\Windows\system32> Resize-VHD -Path "D:\Hyper-V\Virtual Hard Disks\Test-Restore.vhdx" -ToMinimumSize