System Center 2012 R2 Configuration Manager (ConfigMgr 2012 R2) is scheduled to be released soon and there’s a cool new feature that allows us to deploy an operating system and create a Virtual Hard Disk (VHD) at the same time, meaning that we can now deploy an operating system directly to a VHD that can be given to the VMM admins for further use.

Say for example that you have a Virtual Machine Manager administrator who has a project where he needs multiple VMs for production use. The standard procedure would be to manually create a VM, install the OS, install all of the required applications on that VM, and then use that VM on all of the other production machines. Now this all can be achieved by ConfigMgr 2012 R2 using a new Task Sequence (TS) that will do all of this for you in a single process.  Here are the steps ConfigMgr 2012 R2 uses to create this new Virtual Hard Drive:

1) Configuration Manager creates a Task Sequence media.

2) Configuration Manager creates a Virtual Hard Disk.

3) Configuration Manager creates a temporary virtual machine (VM) on the Hyper-V Server.

4) Configuration Manager allocates the resources to the created temporary VM.

5) Configuration Manager mounts the Task Sequence media to the VM.

6) Configuration Manager attaches the VHD to the VM.

7) Configuration Manager executes the Task Sequence.

8) Once the Task Sequence completes, the temporary VM is stopped and the VHD is copied to a share location.

NOTE: While the steps above will create our VHD, there is an additional prerequisite that is required. In addition to the standard prerequisites for VMM (see http://technet.microsoft.com/en-us/library/gg610592.aspx), we also need a server with Hyper-V running on it, and this server needs to have the ConfigMgr 2012 R2 console installed.

Here is an example of how we can deploy an operating system to a Virtual Hard Drive using ConfigMgr 2012 R2:

First we select our new type of Task Sequence that allows us to install an existing Windows image package to a Virtual Hard Drive:

clip_image002[4]

The rest of the Task Sequence is essentially the same as a regular Task Sequence, however there is an extra step that is added as part of this new Task Sequence: The “Shutdown computer” step.

clip_image004[4]

This is an important part of the TS as this step allows the VM to shut down and then pass control to Configuration Manager to copy the VHD package. Once we have created the Task Sequence to deploy an OS to a Virtual Hard Disk, we will create the Virtual Hard Disk itself. To create this, we now have an additional node in Operating Systems for “Virtual Hard Disks”.

clip_image006[4]

Note that if the Configuration Manager server is not a Hyper-V host we will not get the option to create a Virtual Hard Disk as Configuration Manager needs to interact with the hypervisor to create the virtual machine, perform all the steps in the TS, and then delete the VM. In this process, the Configuration Manager console interacts with Hyper-V which is why we require a dedicated Hyper-V server with the ConfigMgr 2012 R2 console.

Below is a screen shot from my Hyper-V server that has the ConfigMgr 2012 R2 console installed.

clip_image007[4]

In the Create Virtual Hard Drive wizard, we specify the general description of the Virtual Hard Disk and a share location to store the VHD file created during the process.

clip_image009[4]

The next step allows you to select the Task Sequence for deployment. Make sure to select the Task Sequence we created for the Virtual Hard Disk. You will see the option to select other kinds of Task Sequences but those will fail.

Once we select our Task Sequence we have a preview of all the packages in the TS.

clip_image011[4]

After this step we get to see the introduction of another new feature in ConfigMgr 2012 R2, a preview of the packages which are required in a TS and their distribution status on the Distribution Point (DP).

clip_image013[4]

We can clearly see in the above screen shot that there are 3 packages required in my TS and out of them 2 are not on the DP. This is a hard block now and we will not be able to proceed until we distribute all of the required packages to the DP.

After distributing the packages, we also get the option to choose which DP will be used to download these packages. This has an added bonus of allowing us to isolate DP related issues and package related issues we may run into after running the Task Sequence.

clip_image015[4]

Here is a preview showing the available Distribution Points and the package distribution status.

clip_image017[4]

We also have a preview that shows the DP selected to be used by the Task Sequence to download the required packages.

Once we initiate this wizard, the Operating System Deployment to the Virtual Hard Drive begins.

clip_image019[4]

This wizard can be monitored by a log file named DeplottoVHD.log. This log is found in the AdminUILOG folder in the Admin console installation Directory.

clip_image021[4]

As seen here, the wizard’s first step is to create a Task Sequence media. This creation of the media can be seen in DeploytoVHD.log which is monitored by the CreateTSMedia component and logged in the AdminUILog folder.

clip_image023[4]

This is the same process that is logged when we create a normal Task Sequence media except for the fact that in this case TS media is created by Configuration Manager and mounted to the temporary VM.

Once the TS Media is created, the Deploy to VHD component comes into the picture. This creates a temporary VM, allocates the necessary resources to the machine, mounts the TS media and starts the execution.

clip_image025[4]

The CreateTSMedia.log snippet above shows that the process of Task Sequence media creation has completed.

clip_image027[4]

Above in our DeploytoVHYD.log we can see Configuration Manager creating a virtual machine, allocating the resources, mounting the TS media, attaching the VHD and starting the VM.

This log will pause here for some time and wait for the Task Sequence to complete the deployment.

clip_image029[4]

clip_image031[4]

We can see above how a temporary virtual machine is created on the Hyper-V server.

Once the Task Sequence completes on the virtual machine, the machine will be shut down and the VHD created as part of the TS will be copied to the shared location specified in the Create Virtual Hard Disk wizard.

clip_image033[4]

The snippet above of the DeploytoVHD.log shows that after waiting for the VM to shut down, the VHD was copied to the shared location.

Once the Wizard is complete we can see our VHD in the create VHD node with the description we entered previously.

clip_image033[4]

The snippet above of the DeploytoVHD.log shows that after waiting for the VM to shut down, the VHD was copied to the shared location.

Once the Wizard is comple45EA8179.jpg">clip_image035[4]

We might now be thinking of what can we do with this VHD and the answer lies on the same Create VHD node. As we all know, Virtual Machine Manager is part of the System Center suite which includes Configuration Manager, and now with ConfigMgr 2012 R2 we can upload this VHD created by Configuration Manager to your Virtual Machine Manager server directly.

clip_image037[4]

Now your VHD is ready to be used by your VMM 2012 administrators.

NOTE: For additional information, see How to Manage Virtual Hard Disks in Configuration Manager at http://technet.microsoft.com/en-us/library/dn448591.aspx.

Original author: Ashish Kumar via http://blogs.technet.com/b/configurationmgr/archive/2013/10/31/new-in-system-center-2012-r2-configuration-manager-deploying-an-operating-system-to-a-virtual-hard-drive-vhd.aspx