We are going to run the utility programs on a physical host machine running Windows Server 2012 R2 Standard x64 Edition SP2 (or later) in a Hyper-V role.
The guest OS installed on the .vhdx used in this example is Windows Server 2003 R2 Standard Edition SP2 (x86). But this works for nearly all guest OS including Windows XP, Windows 10 x64 and Windows 2012 R2 x64 all the way up to Windows Server 2019.
This technique is known to work using .vhd and .vhdx images holding machines running Windows 2003 R2 OS and later. If you are running Windows Server 2012 R2 in the virtual machine, it will not be necessary to run the DISKPART utility from the command line in the physical host, you can do all you need to do to accomplish the expansion by changing the settings alone.