We are going to run the utility programs on a physical host machine running Windows Server 2012 R2 Standard x64 Edition SP2.
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.
This technique is known to work using .vhd and .vhdx images holding machines running Windows 2003 R2 OS. 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.