Windows VersionsBy default a single operating system is linked to a task sequences in Microsoft Deployment Toolkit (MDT). This means that if you have different operating systems you need to built (and maintain) a task sequence for each operating system.

A customer has different client types and wants to use a single task sequence to deploy different images. For this purpose a custom task is added that selects an operating system based on the prefix of the provided computer’s name.

 

Naming convention

The customer has a naming convention which uniquely identifies the different client types. Simply put, the first two characters determine the client type followed by a numerical identification number.

AAnnnn

Where AA is the computer type and nnnn is the numerical identification number. The following computer types are available:

Computer name prefix Description
MC Medical clients
NB Notebooks
PC Workstations
VC Vendor clients

Based on the naming convention the following machines could exist: MC1234, NB4321, PC1494, VC2598, etc.

 

Operating Systems

Besides unattended installations MDT can deploy images (injecting model specific drivers) captured from a reference machine. These images are stored as Windows Imaging Format files (the same format that’s used to boot and install Windows operating systems) and a referred to as Operating System.

For each client type an image is captured and added to MDT as an operating system.

Deployment Share - Operating Systems

The name of the operating system in MDT is AA-BB where AA is the computer type and AA is the platform of the operating system (x86 or x64).

Based on the naming convention the following operating systems could exist: MC-x86, MC-x64, PC-x86, PC-x64, etc.

 

 

Task Sequence

Each task sequences has a reference to a single operating system, the base properties of this OS determine the how the task sequence is built-up (for instance which unattended.xml).

Image Deploy x86 Properties - OS Info

The identifier of the OS is stored as OSGUID in the globalVarList in the ts.xml for for that task sequence.

Control - IMG-DEPLOY-x86 - ts.xml

 

 

Install Operating System

The “Standard Client Task Sqeuence”  template contains a task Install Operating System which will install the operating system on the client. The operating system provided during the creation of the task sequence is stored at this task AND in the OS Info tab of the task sequence, I recommend choosing the default WIM file of the Windows installation your deploying, not a captured image.

Image Deploy x86 Properties - Install Operating System

 
Select OS based on OSD computer prefix

Right before the operating system is installed an operating system is selected based on the name of the computer. A Run Command Line task is added to execute a custom script:

cscript.exe "%SCRIPTROOT%\Z-CustomSelectOSBasedOnComputerPrefix.wsf"

This script will determine the prefix of the computer name, the first two characters of the OSD Computer Name, and select the operating system whose name matches the prefix of the computer name + the operating system platform.

Image Deploy x86 Properties - Select OS based on OSD computer prefix

 

 

Z-CustomSelectOSBasedOnComputerPrefix.wsf

The script that determines the OS to install, called from the task sequence, is relatively easy. It executes a number of tasks:

  • Determines the name of the new computer (OSDComputerName)
  • Stores the environment variable OSDComputerNamePrefix containing the prefix (first two characters) of the new computer name
  • Iterates trough all operating systems in MDT. If the operating systems matches the criteria it will replace the OSGUID environment variable with the identified of the found operating system
    • The operating system must be Enabled
    • The platform of the operating system (x86 / x64) must match the platform of the task sequence
    • The name of the operating system must match the prefix of the new computer name + the platform of the task sequence (eg. PC-x86 or NB-x64)
  • If no matching OS is found an empty GUID is returned, this will fail the installation (this is by wanted behaviour)
 
Log

The script will log all output to Z-CustomSelectOSBasedOnComputerPrefix.log, (and BDD.log)  this helps you troubleshoot the selection of an operating system.. Z-CustomSelectOSBasedOnComputerPrefix.log

 
Download
Z-CustomSelectOSBasedOnComputerPrefix.wsf

 

 

.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

en_USEnglish