Jump to content


anyweb

how can I use the new VHD feature in System Center 2012 R2 Configuration Manager

Recommended Posts

Introduction

 

Microsoft released System Center 2012 R2 Configuration Manager on October 18th, 2013 as planned (General Availability) and now we all have the ability to test the new features in the finished product. I've installed it in my lab and wanted to test the New operating system deployment features, one of which is the ability to create a VHD from a task sequence right from the Configuration Manager console.

 

Before getting started however you'll need to have at least one host capable of running HyperV (such as Windows 8, Windows 8.1, Windows Server 2008R2, Windows Server 2012, Windows Server 2012R2) with the System Center 2012 Configuration Manager console installed.

Tip: You'll need System Center 2012 R2 Configuration Manager installed, here's a step by step guide to get your started.

Step 1. Create a new task sequence
Note: Perform the following on any computer with the System Center 2012 R2 Configuration Manager AdminConsole installed as SMSAdmin.

Open the Admin console, expand Software Library, Operating System Deployment and right click on Task Sequences, choose Create Task Sequence.

Create Task Sequence.png

 

choose the third option, install an existing image to a virtual hard disk

 

Install an existing image package to a virtual hard disk.png

 

choose a suitable name for your task sequence and select a boot image

 

create task sequence wizard.png

 

In this task sequence I am deploying Windows 8 X64 Enterprise using the Install.wim file from the DVD, I also select to enable the Administrator account and I specify a password

 

install the windows operating system.png

 

select to Join a domain and fill in appropriate domain join credentials

 

join domain.png

 

and install the configuration manager client, you can add switches here if needed

 

install client.png

 

and select to install some applications if you wish

 

Install applications.png

 

click next through to the completion message

 

task sequence created.png

 

You can now edit the task sequence if you wish and add/remove steps, note the last step is a shutdown command, this is a special step and is 'looked for' by the wizard later on so that it knows the task sequence is complete and to generate the VHD.

 

shutdown computer.png

 

 

Step 2. Create a Virtual Hard Disk

Note: Perform the following on a HyperV host computer with the System Center 2012 R2 Configuration Manager AdminConsole installed as SMSAdmin.

 

Method #1 - Do it using the AdminConsole

 

In the Admin console Expand the Task Sequences node in Operating System Deployment and right click on Virtual Hard Disks. If this is greyed out it's because you are not running the console on a Hyperv Enabled host (I've tested it on Server 2012 running Hyperv with the R2 admin console installed). To make it clear, i'm including two screenshots of the same action, one on a hyperV host, the other is an adminconsole with no hyperV hosts locally installed.

 

Note: the below screenshot is on a host without hyperv installed or enabled. Note how the Create Virtual Hard Disk action is greyed out.

 

Create Virtual Hard Disk greyed out.png

 

Note: the below screenshot is on a hyperv host

 

Create Virtual Hard Disk.png

 

Now that we've started the create virtual hard disk wizard, fill in some details about our virtual hard disk.

 

specify general information for this virtual hard disk.png

 

next select our task sequence that we created in Step 1

 

select the task sequence.png

 

and depending on how complicated the task sequence was it will take some time to generate a list of task sequence referenced content

 

this task sequence references the following content.png

 

select a distribution point that has all the packages on it (XX of XX)

 

6 of 6.png

 

and click your way through the wizard, at this point you'll see be prompted to allow access to your host computer (to create the file) and shortly after the magic begins

 

progress.png

 

The task sequence media creation is logged in the CreateTSMedia.log file located on the hyperv host running the adminconsole (Typically C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\AdminUILog)

 

createtsmedia log file.png

 

The user you are logged in as will have it's AppData\Local\Temp dir used as a temporary scratch space, so make sure you have lots of space if needed or use the link at the bottom of this page to change your TMP environment variables to point to a drive with more free space.

 

appdata temp.png

 

and off it goes creating the virtual hard disk (look at this video to see the process in more detail, watch above the hyperv4 vm to see the new virtual machine being created, this video has no audio yet, it's coming hopefully if i get time...)

 

youtube video.png

 

creates the virtual hard disk.png

 

This involves, automatically creating a temporary virtual machine in hyperV, starting it automatically, starting the task sequence automatically and finally sealing the VHD file which can then be seen in the configuration manager console. Below you can see the temporary virtual machine in hyperv shortly before the VHD is created (task sequence is complete)

 

our temporary virtual machine.png

 

The temporary virtual machine continues to run the task sequence, eventually installing our applications

 

the vm is running the task sequence.png

 

once complete the Virtual machine shutsdown and the VHD copying starts, you can now monitor the DeploytoVHD.log file (in C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\AdminUILog)

 

deploytovhd log file.png

 

When the logfile confirms the process is done then you can assume that the wizard is also complete...and it is... :-)

 

vhd wizard done.png

 

and you'll notice that the temporary virtual machine is gone

 

temp vm gone.png

 

and clicking on Virtual Hard Disks in the Admin console will list our newly created VHD file, success !

 

newly created vhd file.png

 

at which point you can modify the VHD (by choosing that action in the ribbon or via right click) or just upload it to Virtual Machine Manager.

 

Upload to virtual machine manager.png

 

 

Method #2 - Do it using PowerShell

 

Start PowerShell ISE (PowerShell Integrated Scripting Environment) as Administrator

 

start ISE.png

 

and paste in the following code

import-module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'
Set-Location P01:\
New-CMVhd -path \\hyperv-5\c$\hyper-v\vhd\PowerShell.vhd -Name "Windows 8 Enterprise X64 - VHD created using Powershell " -VHDsize 50 -TaskSequencePackageId "P0100071" -DistributionPointServerNames SCCM.server2008r2.lab.local -Version "X64" -Description "created by windows-noob.com"

The first two lines simply import the configuration manager powershell module and then set your path to your primary server P01.

The New-CMvhd cmdlet is a new cmdlet in R2 and it is used to create the VHD using powershell.

 

In the above, the -TaskSequencePackageId value is the PackageID of your task sequence, make sure to set the appropriate values in the New-CMvhd command to suit your environment (for example your server share).

 

package ID.png

 

Click on the Green arrow to run your powershell script

 

run the powershell script.png

 

and off it goes !

 

script is running.png

 

and after some VHD creation...............job done !

 

complete.png

 

and our VHD appears in the console

 

finished.png

 

not too bad eh ?

 

cheers

niall

 

Related reading

 

Share this post


Link to post
Share on other sites

Thanks for the excellent post, Niall.

 

I know it's an old one, but I'm having issues getting this to work. It builds the VHD, turns off the VM, then fails at "Getting the OS Information". The following is in the log:

 

Getting the OS information.
No drive letter for VHD C:\Users\admin\AppData\Local\Temp\20141020-150542-7PDVZ2BNJA294FNC.vhd.
MountVHD() failed. 0x80070003.
GetVHDOSInformation failed; 0x80070003
wmain failed; 0x80070003
DeployToVHD failed.
I'm running the console as admin on my Windows 8.1 machine with Hyper-V enabled (obviously). This happens with Windows 7 and 8.1 builds. New task sequence created as above. Can't find any info on the internet regarding errors creating VHDs, so I'm a bit stumped.
Any ideas?
Thanks!

Share this post


Link to post
Share on other sites

the 80070003 error means

The system cannot find the path specified.

Source: Windows

but why you are seeing that i don't know, can you post the entire deploytovhd.log file please, are you out of space on the drive it's creating the vhd on

Share this post


Link to post
Share on other sites

the 80070003 error means

The system cannot find the path specified.

Source: Windows

but why you are seeing that i don't know, can you post the entire deploytovhd.log file please, are you out of space on the drive it's creating the vhd on

 

 

Sorry for the late reply. Wasn't out of space on the drive, but gave up in the end anyway, as it wasn't really worth the effort.

 

Thanks for the help anyway!

Share this post


Link to post
Share on other sites

hi .

 

 

i am not sure this post is open. i am trying to deploy the VHD using sccm as mentioned above. BUt getting the error

 

Getting the OS information.
No drive letter for VHD C:\Users\xxxxxx\AppData\Local\Temp\20150119-061546-THZY0HW1NQPX0Y9N.vhd
MountVHD() failed. 0x80070003.
GetVHDOSInformation failed; 0x80070003
wmain failed; 0x80070003
DeployToVHD failed.
Any one to help ?

Share this post


Link to post
Share on other sites

Great guide, thanks :)

one question - when i do this my Hyper-V machine doesn't have a NIC assigned to it, despite a virtual switch being available, any ideas on how to get it to automatically populate one?

Share this post


Link to post
Share on other sites

Thanks for the post, excellent as always! Do you know if it's possible to create a VHDX file using this method? Or would I have to convert it from a VHD file? Thanks for any help you might be able to give me.

Share this post


Link to post
Share on other sites

thanks, not that i know of but who knows, maybe in a coming version it will support it (for things like HyperV Gen 2).

 

meanwhile you can convert them using methods such as this

 

https://support.microsoft.com/en-us/kb/2799257

Share this post


Link to post
Share on other sites

hello,
can you help me?
to the creation of the VHD , the sequence stops at the first step : creation ..

Here are below the error message :

 Erreur : Général

Fichier : \\SV2k12PRT899\c$\Users\Public\Documents\Hyper-V\Virtual hard disks\Win8x64.vhd

Nom : windows 8 Entreprise X64 - VHD

Version : X64

Description : Creating a vhd with system center 2012 R2 Configuration Manager.

Séquence de tâches : FR1000CF-Windows 8 en std Full update

 

the log file shows this:

 

Staging OS Image Package FR1000A9 CreateTsMedia 22/06/2015 12:03:48 4732 (0x127C)
File splitting is required because file size exceeds max file size. CreateTsMedia 22/06/2015 12:03:48 4732 (0x127C)
Total file size is 4308 MB, max ISO file size is 4095 MB CreateTsMedia 22/06/2015 12:03:48 4732 (0x127C)
Failed to open registry key 'Software\Wow6432Node\Microsoft\Windows Kits\Installed Roots', unable to find location of ADK CreateTsMedia 22/06/2015 12:03:48 4732 (0x127C)
Failed to split WIM file (0x800700ea) CreateTsMedia 22/06/2015 12:05:43 4732 (0x127C)
Failed to split WIM file CreateTsMedia 22/06/2015 12:05:43 4732 (0x127C)
Error executing statge StageOsImagePackage CreateTsMedia 22/06/2015 12:05:43 4732 (0x127C)
Error executing first single pass CreateTsMedia 22/06/2015 12:05:43 4732 (0x127C)
Failed to create media (0x800700ea) CreateTsMedia 22/06/2015 12:05:43 4732 (0x127C)
CreateTsMedia failed with error 0x800700ea, details='FR1000A9' CreateTsMedia 22/06/2015 12:05:43 4732 (0x127C)
CreateMedia.exe finished with error code 800700ea CreateTsMedia 22/06/2015 12:05:43 8584 (0x2188)

 

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.