Powershell script/function to expand system/boot disk on Windows XP/2003 VMs

In Windows 7 and Server 2008 virtual machines and above, expanding the boot/system disk is a simple matter of expanding it in the hypervisor, then expanding it in the guest OS in the Computer Management/Disk Management GUI. In Windows XP/Server 2003 guest VMs, expanding the boot/dystem disk is not available via native Windows tools.

This script leverages Server 2012 R2 hypervisor capabilities to expand boot/system disk on a guest VM running Windows XP/2003 OS. The script leaves a log file behind listing steps taken. The script can be downloaded from the Microsoft Script Center Repository.

To use it: Download the attached file, unblock it, adjust PS execution policy as needed, run the script to load the function in memory, then use this line to get detailed help and examples as shown below:


Note: The script will shutdown the VM during this process.

For example, if you down the VM, and expand the disk in Hyper-V Manager GUI:


In the VM, you cannot expand the boot/system partition with native Windows 2003/XP tools:


You can do that with this script. On the Hyper-V host where the VM is running, run:

Expand-C -VMName MyVM1 -Size 17GB -BackupPath "d:\save"

The script will

  • Backup the VHDX file before expanding it if the ‘BackupPath’ is used
  • Convert the file from VHD to VHDX format if it was a VHD file. In this case you’ll need to delete the old .vhd file manually.
  • Down the VM (gracefully)
  • Expand the VHDX file
  • Expand the partition
  • Re-attach the C: drive disk file to the VM
  • Start the VM Diskc8
  • Leave a log file listing the steps taken Diskc9




3 responses

  1. Hello Sam,
    Sorry for my English, I’m a french IT Guy. Some years ago i found a solution with the “extpart.exe ” Tools from Dell, it will do an expand of the system disk with less step. It will do it in live !!
    Thank you for sharing your experience, I will test your solution too.

    October 25, 2014 at 6:44 am

    • this is the post where I describe the solution. http://blog-de.mescouill.es/augmenter-la-taille-dun-disque-de-base-avec-extpart/

      October 25, 2014 at 6:46 am

  2. Hi Perez,
    This looks interesting. I’ll test it shortly. Thanks for the link..

    October 26, 2014 at 7:02 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.