Using MDT 2010 to Deploy Windows 7 to a VHD

I was getting caught up on some blog reading over my lunch hour and noticed a new post by the Deployment Guys on their blog. If you didn’t know, with Windows 7, you can now boot from VHD; there is even a trick to make Windows Vista boot from VHD. Booting loads the VHD and uses your physical hardware, its a great way multi-boot a computer into an OS that is VHD aware. In the Microsoft world, at this point in time, this means Windows 7 and Windows Server 2008 R2.

The post from the Deployment Guys blog explains how to deploy Windows 7 using Microsoft Deployment Toolkit 2010 (MDT 2010) to a computer and instead of deploying to Disk 0 Partition 1, it is set to deploy to VHD file.

How to Setup MDT to Create a Boot from VHD Deployment

So how do we do this? Here’s the point form version. (You can get pictures from the Deployment Guys blog)

  1. Create a task sequence to deploy Windows 7
  2. You are going to insert 3 steps in the Pre-Install \ New Computer only phase
  3. Edit the task sequence that changes how the drive is partitioned (I presented how to do this at TechDays Ottawa). In this case we don’t want to partition or format the drive. Disable this task sequence.
  4. Insert a Set Task Sequence Variable Step named Set Boot VHD Location. You set the location of the VHD file is by setting the Task Sequence Variable to BootVHDLocation and set the Value to the location where you want the file to exist. (for example C:\Boot1Windows7.vhd) Ensure that the file you named in the variable doesn’t already exist.
  5. Insert a Set Task Sequence Variable Step named Set Boot VHD Size. Set the task sequence variable to BootVHDSize and set the value to the maximum size you want the VHD to be. Ensure you have enough space to grow to the maximum.
  6. Insert a Run Command Line Step and call it Setup VHD. The command line is cscript.exe “%SCRIPTROOT%\ZTIDiskPartVHD.wsf (There is no start in value.)
  7. Download the script ZTIDiskPartVHD.wsf and copy is to your Distrobution$\Scripts folder. The link to the script is at
  8. Run your task sequence on a computer and it will install Windows 7 into a VHD.

This doesn’t work on machines that use Bitlocker to encrypt the drive.

The full article can be found at: They have pretty pictures to help you out.

This is a really smart way to boot into different environments. You can have different VHD images for different tasks, ie. One for programming, one for gaming, etc. Pretty sweet and easy to deploy when using MDT


About Todd

I am a Microsoft MVP, MCSE and MCT who lives in Kingston, Ontario.

One Thought on “Using MDT 2010 to Deploy Windows 7 to a VHD

  1. Hi,
    I’m trying to create a script that will clean the disk before creating the VDisk and add the type of VDISK I want to create… And mine doesn’t work.
    if oEnvironment.Item(“BootVHDLocation”) “” then

    DiskPartWrite oExec, “REM ————–”
    DiskPartWrite oExec, “REM BOOT VHD Provisioning…”
    DiskPartWrite oExec, “Select disk 0”
    DiskPartWrite oExec, “Clean”
    DiskPartWrite oExec, “Create Part Pri”
    DiskPartWrite oExec, “Format fs=NTFS label=”Win7x86″ quick”
    DiskPartWrite oExec, “Assign letter=C”
    DiskPartWrite oExec, “Create vdisk file='” & oEnvironment.Item(“BootVHDLocation”) & “‘ MAXIMUM=” & oEnvironment.Item(“BootVHDSize”) & “‘ TYPE=” & oEnvironment.Item(“BootVHDType”)
    DiskPartWrite oExec, “Select vdisk file='” & oEnvironment.Item(“BootVHDLocation”) & “‘”
    DiskPartWrite oExec, “Attach vdisk”
    DiskPartWrite oExec, “Create partition primary”
    sNextDriveLetter = split(sFreeDrive,vbTab)(iNextFreeDrive)
    if sNextDriveLetter “” then
    sNextDriveLetter = left(sNextDriveLetter,1) & “:” ‘ Normalize path
    DiskPartWrite oExec, “Assign letter=” & sNextDriveLetter
    oEnvironment.Item(“DestinationLogicalDrive”) = sNextDriveLetter
    oLogging.CreateEntry “Failed to assign a drive letter”, LogTypeError
    ZTIProcess = FAILURE
    end if
    sFormatCommands = oEnvironment.Item(“DestinationLogicalDrive”) & ” /FS:NTFS /V:BootVHDDisk /Q /Y”
    end if

    Can someone help please ?

Post Navigation

%d bloggers like this: