By 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.
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.
Where AA is the computer type and nnnn is the numerical identification number. The following computer types are available:
|Computer name prefix||Description|
Based on the naming convention the following machines could exist: MC1234, NB4321, PC1494, VC2598, etc.
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.
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.
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).
The identifier of the OS is stored as OSGUID in the globalVarList in the ts.xml for for that task sequence.
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.
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:
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.
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)