We've all been there. You created a virtual machine disk file as either fixed or dynamic, only to realize later that you needed to have the opposite disk type. Ben Armstrong comes to the rescue with a VBScript to do just that, programmatically change one disk type to another.
set vsApp = CreateObject("VirtualServer.Application","localhost")
TargetVHDpath =Inputbox("Enter path and name of VHD to convert:")
FixedVHDpath =Inputbox("Enter path and name of VHD to create")
set target = vsApp.GetHardDisk(TargetVHDpath)
set convertTask = target.convert(FixedVHDpath,1)
while not convertTask.isComplete
wscript.echo "Conversion is " & convertTask.PercentCompleted & "% complete"
WScript.Sleep 2000
wend
wscript.echo
wscript.echo "Conversion complete"
NOTE:
- Use CSCRIPT.EXE to run the script, and
- The script converts a dynamic disk to a fixed disk. To do the opposite, change the "1" to "0" in the .convert() call.
To comment or thank Ben, visit his original post on his site,
here.