MDT 2013: Creating a New Template

This script will create a new MDT task sequence template based on the “Client.xml” file and adds it to the list of available templates.  It adds a few “extra” features, which are listed below.

Template Name: Windows 10 Client Task Sequence
Added Features:
1) Adds a custom step for a drivers path variable “DriverGroup001“, utilizing %Make% and %Model% variables.
2) Changes the “DriverSectionProfile” from “All Drivers” to “Nothing”.
3) Changes the name and title of the template.

This script should be forward compatible with new versions of MDT 2013 and is best run against a non-modified “Client.xml” file.  So no need to copy anything over to new versions of MDT.

This script has been extracted from a much more comprehensive (complicated) MDT 2013 Deployment script.
Someday I will post the whole script…

 

##############################################
# Uses the "Clients.xml" file to create a new template and creates
# a "Win10_Clients.xml" file in the "Templates" folder when completed.
#
# The new template is designed for Windows 10 and has a few changes.
#  1) Adds a custom step for a drivers path variable "DriverGroup001".
#  2) Changes the "DriverSectionProfile" from "All Drivers" to "Nothing".
#  3) Changes the name and title of the template.
#
$ts_step = @"
    <step type="SMS_TaskSequence_SetVariableAction" name="Set Drivers Path" description="" disable="false" continueOnError="false" successCodeList="0 3010">
      <defaultVarList>
        <variable name="VariableName" property="VariableName">DriverGroup001</variable>
        <variable name="VariableValue" property="VariableValue">Windows 10\%Make%\%Model%</variable>
      </defaultVarList>
      <action>cscript.exe "%SCRIPTROOT%\ZTISetVariable.wsf"</action>
    </step>
"@
$ts_tmpl               = "$env:programfiles\Microsoft Deployment Toolkit\Templates\"
$ts_ref                = "$($ts_tmpl)Client.xml"
$tsXML                 = (Get-Content $ts_ref)
$new_node              = $tsXML.ImportNode($ts_step.get_DocumentElement(), $true)
$task_node             = $tsXML.SelectSingleNode('//sequence/group/step[@type="BDD_InjectDrivers" and @name="Inject Drivers"]')
$task_inner            = $task_node.defaultVarList.variable | Where-Object {($_.Name -like "DriverSelectionProfile") -and ($_.Property -like "DriverSelectionProfile") -and ($_.'#text' -like "All Drivers")}
$task_parent           = $task_node.ParentNode
$task_inner.'#text'    = "Nothing"
$ts_header             = $tsXML.sequence | Where-Object {($_.Name -like "Standard Client Task Sequence") -and ($_.Description -like "A complete task sequence for deploying a client operating system")}
$ts_header.name        = "Windows 10 Client Task Sequence"
$ts_header.description = "A complete task sequence for deploying a Windows 10 client operating system with model specific driver support"
$task_parent.InsertBefore($new_node,$task_node)
$tsXML.Save("$($ts_tmpl)Win10_Client.xml")