Hyper-V Program Manager
Differencing disks store a reference to their parent virtual hard disks. If the parent virtual hard disk is moved, or renamed, the differencing disk will stop working - which will in turn stop any virtual machine that is using the differencing disk from starting up. You can correct this problem through the Virtual Server user interface (by inspecting the differencing disk in question), or you can use a script like this:
CONST vmDiskType_Dynamic = 0
CONST vmDiskType_FixedSize = 1
CONST vmDiskType_Differencing = 2
dim vs, aVHD, parentVHD, aVHDFileName, parentVHDFileName
'Grab command line arguments
aVHDFileName = WScript.Arguments.Item(0)
parentVHDFileName = WScript.Arguments.Item(1)
'Connect to Virtual Server
Set vs = CreateObject("VirtualServer.Application")
'Create VHD object
set aVHD = vs.GetHardDisk(aVHDFileName)
set parentVHD = vs.GetHardDisk(parentVHDFileName)
'Merge the VHD to a new dynamic disk
if aVHD.type = vmDiskType_Differencing then
wscript.echo "Changing the parent virtual hard disk..."
aVHD.Parent = parentVHD
As you can see, this script takes two command-line parameters. The first is the name of the differencing disk, and the second is the name of the new parent virtual hard disk (note that these both need to be full paths, and not relative paths. e.g. "C:\foo\parent.vhd" not "..\..\foo\parent.vhd"). It then creates VHD COM objects for both, and sets the differencing disk to use the new parent disk.
I'm actually stuck trying to figure out the script for how to create and link a differencing disk to a VM in the first place.
I can create and link a normal differencing disk, but none of the sample code I can find tells me how to create a differencing disk for a new VM.
Oops, meant to say I can do a normal dynamic disk, but can't figure out how to script a differencing disk.