Citrix Image creation

Automated Master Image Creation



When deploying a new computer or server image using MDT / SCCM, one of the most time consuming parts is Windows Update. So if the reference image isn’t getting updated on a regular basis, the deployment time will increase each and every month.

To achieve the fastest deployment the reference image should be automatically updated with the recent Windows Updates at least once a month.

Automated Master Image Creation-02

The recommended platform for building references images is the free Microsoft Deployment Toolkit, even if the images is going to be used with SCCM. So let’s get started with Automated Master Image Creation.

Open CustomSettings.ini for your Build Deployment share and add the following to the top:

And at the bottom you add a section for each and every OS type you want to automate with the correct MAC Address:

If you’re using Windows 2008 R2 or Windows 7 you should add the ProductKey= as well to skip the licensing screen.

Automated Master Image Creation-03

To be able to move a captured image to the correct location in a Task Sequence you need to create a script in the scripts catalog, in my case \mdt-01.ctxlab.localMDTBuildLab$Scripts.

Call the script Realocate.cmd and add the following:

And then add a Command Line task at the end with this command:

Automated Master Image Creation-04

So in the example above, if a computer with the MAC Address 00:15:5D:01:FB:32 boots on the ISO it will automatically start the Task Sequence W81, capture the image, move it to the Production Deployment Share and shutdown the computer.

All this without lifting a finger, a real zero touch deployment. Relax and check theAutomated Master Image Creation status now and then from you mobile device.

Automated Master Image Creation-05

Wouldn’t it be cool if we could leverage PowerShell to automatically build the master images as a Schedule Task? The following script will create and start a Hyper-V VM with the correct MAC Address and delete it when the capture is finished.

To further improve the building time of the reference images, the captured images should be copied back to the MDT Build Deployment Share once in a while. This way you will update the latest version instead of the base Microsoft ISO image with hundreds of Windows Updates.

So how long does it take to deploy Citrix XenDesktop 7.1 totally automated which Gunnar Berger referred to above? 28 minutes from start to finish, including GPMC and the SCVMM Console.

To further reduce time and space take a look at this article from fellow CTP Aaron Parker : Cleaning up and Reducing the Size of your Master Image.

To learn more check my free training on Automated Master Image Creation.


Cleaning up and Reducing the Size of your Master Image

Compressed Car

There’s typically not too much that you can do to reduce the size of your master image. You might use application virtualization or layering solutions to reduce the number of master images, but once you work out what needs to go into the core image, that’s going to dictate the size of the image.

Reducing the size of your master image can help reduce the capacity required to store master images and virtual machines (dedupe helps, of course) and spend less cycles transmitting an image across the network for physical PCs.

An easy win, is running the Disk Clean-up tool included in Windows (since Windows XP) and fortunately this tool can be automated to run at the end of a build (e.g from MDT or ConfigMgr). For physical PCs or persistent desktops, this tool could even be run as a scheduled task.

Microsoft released an important update for Windows 7 last year that can result in a significant reduction in disk space: Disk Clean-up Wizard addon lets users delete outdated Windows updates on Windows 7 SP1. The same feature was originally delivered with Windows 8. (Windows 8.1 Update 1 is expected to reduce disk space requirements again).

Here’s an example system where I’ve run the Disk Clean-up tool that has resulted in a 3.4 GB reduction in disk usage – on the left is the before image, on the right is after the cleanup. (I’m cheating a bit here, this is a system that has gone from Windows 7 to Windows 7 SP1, hence the reason for such a large change).

Compare Disk Cleanup Before and After

Disk Clean-up can remove a number of interesting items, most of which will actually be applicable for PCs and persistent desktops post-deployment. Here’s the items that Disk Clean-up can manage on Windows 8.1:

Disk Cleanup options

To automate Disk Clean-up, use the following steps:

  1. Elevate a command prompt
  2. Run CLEANMGR /SAGESET:<number> (where <number is any number between 1 and 65535)
  3. Select each of the items to clean up
  4. Click OK

To run Disk Clean-up from a script run CLEANMGR /SAGERUN:<number> (where <number> is the same number use with SAGESET.

To automate the process of running Disk Cleanup, the following script can be used to enable all of the tool’s options in the registry and then execute the cleanup process. This script should work for both Windows 7 and Windows 8 and would be useful to run at the end of a deployment. This example uses 100 as the configuration setting, so you would run CLEANMGR /SAGERUN:100 to run Disk Cleanup with these settings.

It’s important to note that while Disk Clean-up exists on Windows 7 and Windows 8, it does not exist on Windows Server unless the Desktop Experience feature is installed (i.e. a Remote Desktop Session Host).

If your image is Windows 8.1 or Windows Server 2012 R2, then the following command is available to perform an even more in depth cleanup of the WinSXS folder, making some additional space available:

Running Disk Clean-up and the above DISM command in a script to clean up your master image should result in a smaller image. Don’t forget that this approach is also useful for persistent desktops – unless you’re using some type of dedupe solution, then there’s potentially gigabytes per desktop that can be removed.

There is one more method worth for reducing space worth mentioning – the Uninstall-WindowsFeature PowerShell cmdlet in Windows Server 2012 and Windows Server 2012 R2. This can go a long way too to reducing the disk footprint by completely removing features from Windows (making them unavailable for install).

For instance, if you’re deploying a Remote Desktop Session Host, there’s no need for IIS or Hyper-V to be in the component store. See this blog post article for full details: How to Reduce the Size of the Winsxs directory and Free Up Disk Space on Windows Server 2012 Using Features on Demand

[May 14 2014] Microsoft has released this update for Windows Server 2008 R2, which can be on the original KB article here: Disk Cleanup Wizard add-on lets users delete outdated Windows updates on Windows 7 SP1 or Windows Server 2008 R2 SP1. The update is available from Windows Update and WSUS.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s