How to setup MDT Reference Image Creation with 100% Automation for Windows 7, Windows 8.1 and Windows 10

Word of Thanks to my OSD friends 🙂

This is my first blog post ever, which has been due long time ago. Before I can begin, I would sincerely like to give full credit to my friend Mikael Nystrom for inspiring me to write this as an alternative to his exceptional post on Image Factory on Deploymentbunny.com. I would also like to extend my Gratitude and Thanks to Johan Arwidmark, Mikael Nystrom, Keith Garner, Michael Neihaus, Aaron Czechowsky, Kent Agerlund, Mike Marable, Niall Brady, Damien Van Robaeys and many more for sharing their knowledge with the community and helping us getting well versed with OSD, MDT and SCCM. So without further adieu, lets us get started.

Get Set OSD 🙂

The main driving force in automating your image creation for Window 7, Windows 8.1 and Windows 10 is based on a fully automated OSD properties settings in your customsettings.ini file which in turn calls the RAM Memory check as a UserExit Script for running logical system queries followed by setting the task sequence properties based on the Create Reference Image Function that is called within the Master Image creation PowerShell script Module.

Your Customsettings.ini should be set fully automated. So make sure that you have all the variables and properties populated for complete automation.

Main Section of the Customsettings.ini file should look like this:

SkipCapture=YES
DoCapture=YES
SkipTaskSequence=YES
SkipComputerName=YES
_SMSTSPackageName=#SetTSPackageName(“%MEMORY%”)#
TaskSequenceID=#SetTaskSequence(“%MEMORY%”)#
UserExit=ZTI-RAMTest.vbs
FinishAction=SHUTDOWN

The Build and Capture task sequences are standard client task sequences within MDT. Please make a note of the Task Sequence IDs that will be referenced within the ZTI-RAMTest.vbs file. If your Task Sequence IDs are different from as shown below, kindly update the ZTI-RAMTest.vbs file accordingly.

wp1.jpg

The Magical ZTI-RAMTest.vbs is a very simple script that runs in WinPE to query the Memory available to the Virtual Machine and sets a corresponding Task Sequence ID and SMSTS Package Name to be consumed during the WinPE phase of the boot up process.

wp2.jpg

The Global settings within the Master Image creation PowerShell script Module are used for setting Memory values to the Virtual Machines being deployed for the Reference Image creation.

$Global:StartUpRAMWin7x64 = 1024*1024*1024*4

$Global:StartUpRAMWin81x64 = 1024*1024*1024*4.5

$Global:StartUpRAMWin10x64 = 1024*1024*1024*5

As evidently shown above, we are assigning different set of RAM – Memory values for Virtual Machines per respective Windows platforms.

For Window 7, we are setting the Memory Value to 4GB

For Windows 8.1, we are setting the Memory Value to 4.5GB

For Windows 10, we are setting the Memory Value to 5GB

The Master Image creation PowerShell script Module has Create and Remove Reference Image functions per Windows Platforms as shown below:

  1. New-AutoGenWin7x64REF
  2. New-AutoGenWin81x64REF
  3. New-AutoGenWin10x64REF
  4. Remove-AutoGenWin7x64REF
  5. Remove-AutoGenWin81x64REF
  6. Remove-AutoGenWin10x64REF

For Instance, when the New-AutoGenWin81x64REF function is called, the Hyper V host creates a new Virtual Machine as guest and sets the memory as 4.5GB based on the global settings variable:

$Global:StartUpRAMWin81x64 = 1024*1024*1024*4.5

Similarly for Windows 7 x64, we call the New-AutoGenWin7x64REF function, which then creates a new Virtual Machine as guest and sets the memory as 4GB based on the global settings variable:

$Global:StartUpRAMWin7x64 = 1024*1024*1024*4

Lastly for Windows 10 x64, we call the New-AutoGenWin10x64REF function, which then creates a new Virtual Machine as guest and sets the memory as 5GB based on the global settings variable:

$Global:StartUpRAMWin10x64 = 1024*1024*1024*5

The Remove-AutoGen functions per Windows Platform can be used to delete the Virtual machine once the capture process is complete and you no longer need the Virtual Machine in question.

Prerequisites

Hyper V Host – Windows 8.1 or higher.
Standard MDT Setup with basic Build and Capture sequences.
OEM Customizations may be integrated if required.

Setting up the Script and Variables

# Global Settings #

Naming the Virtual Machine Guests are set with the below variables (No Change required)

$Win7x64VMName = “Windows 7 x64 SP1 – Reference Build”
$Win81x64VMName = “Windows 8.1 x64 – Reference Build”
$Win10x64VMName = “Windows 10 x64 – Reference Build”

Setting Virtual Machine Memory Values are set with the below variables (No Change required)

$Global:StartUpRAMWin7x64 = 1024*1024*1024*4
$Global:StartUpRAMWin81x64 = 1024*1024*1024*4.5
$Global:StartUpRAMWin10x64 = 1024*1024*1024*5

Setting Virtual Machine VHD Size Value are set with the below variables (No Change required. I have set it to 60GB that should be enough for Reference Machine)

$Global:VHDSize = 1024*1024*1024*60

Setting Virtual Machine Internet facing network switch are set with the below variables. Please change it as per your Hyper V environment. My Internet facing Switch on the Hyper V host is named “External”.

$Global:SWitchName = “External”

Setting Virtual Machine VHD File location are set with the below variables Please change it as per your Hyper V environment.

$Global:VMLocation = “C:\Hyper-V\VMs”

For $ISOFileExist variable Make sure you have copied your updated DeploymentShare Boot Media ISO to the correct location: $ISOFileExist = Test-Path “C:\ISOs\MDT10BuildLab.iso”

Running the script / Module

The Scripts are available at https://1drv.ms/f/s!AljjQEIEs7p2jE7AbXLAuMyYaUFc

The Module / Script may be imported into the Hyper V Host and then appropriate functions may be called as and when required.

To automate the script end to end, simply uncomment out the last 6 lines of the script where we are calling the Create and Remove Virtual machines function per each Windows Platform. You will also need to ensure that the Bootstrap.ini file is also fully automated with appropriate Variable settings as shown below.

DeployRoot=\\<ComputerName>\MDT10BuildLab$
SkipBDDWelcome=YES
UserDomain=<DomainName>
UserID=<UserName>
UserPassword=<Password>

That about it and you have a  fully functional Image factory at your immediate perusal. As Johan calls it, Happy Deployment 🙂

 

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: