If you spend a lot of time creating ConfigMgr 2012 R2 OSD Task Sequences, you probably have a method for inserting the steps and groups that you like to use in every TS you create. Maybe you open a reference TS up and copy and paste steps into a new TS that you are creating. Maybe you export and import your favorite task sequences or just right-click on one and copy it in the console. Wouldn’t it be great if you could just create a template of your favorite task sequences and be able to pick them when running through the Create MDT Task Sequence wizard? Yeah – I was thinking the same thing one day and decided to see if I could do it.
A ConfigMgr Task Sequence is stored in XML. If you use the Get-CMTaskSequence PowerShell cmdlet, you will notice one of the properties is Sequence. This is what gets displayed (and updated) when you use the Task Sequence editor. So, all you need to do is the following:
- Build a TS the way you like it
- Export the TS XML
- Modify it slightly
- Copy it into the MDT directory
- Test it by using the Create MDT Task Sequence wizard
For step #1, depending on the steps that you add in the task sequence, you might need to clean them up a bit. For example, if you have a reference package in a step, you might disable the step if you plan on using the template in another ConfigMgr site. Do the same for anything that is unique or you do not want shared. In these cases, there might be minor edits that need to be made to the task sequence after running through the Create MDT Task Sequence wizard. The benefit is the time saving and all of the groups and steps are in the correct order in the task sequence.
For step #2, export the (XML) contents of Sequence property. If you just dump that value, the XML will be unformatted and if you are like me, that will drive you crazy. With a little help from PowerShell (and my good friend Kaido @ Coretech for the proper syntax), we can dump this to a file all nicely formatted. In my previous post, ConfigMgr 2012 OSD: Automatically Open SMSTS log, I included a template that could be used. I will use this as my example. The name of the task sequence that I created as a reference is called Standard OS Deployment MDT-DEBUG. I want to export the XML to a file called Client Task Sequence – DEBUG.xml. I accomplished this by using the following:
$TS = Get-CMTaskSequence -Name 'Standard OS Deployment MDT-DEBUG' [XML]$XML = $TS.Sequence $XML.Save('e:\1E Demo\Client Task Sequence - DEBUG.xml')
For step #3, there are just a few things that need to be done in order to make it usable with the Create MDT Task Sequence wizard. Add the following to the beginning of the XML:
<?xml version="1.0"?> <SmsTaskSequencePackage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <BootImageID>CEN00006</BootImageID> <Category /> <DependentProgram /> <Description /> <Duration>360</Duration> <Name>Client Task Sequence - DEBUG</Name> <ProgramFlags>152084496</ProgramFlags> <SequenceData>
Be sure to give it the proper name as you want it to show up in the Create MDT Task Sequence wizard drop down box (mine is named Client Task Sequence – DEBUG), and update any other settings you require. The Boot Image ID will get updated by the one that is selected/created in the wizard, so no need to worry about that field. The next thing is to add the following to the end of the XML:
</SequenceData> <SourceDate>2014-09-16T16:00:00</SourceDate> <SupportedOperatingSystems /> <IconSize>0</IconSize> </SmsTaskSequencePackage>
I usually modify the SourceDate as a way of versioning my templates. (Modifying this manually shows what needs to be done, however, this whole process could be automated using PowerShell.)
For step #4, save the file and copy it into the SCCM directory where the Microsoft Deployment Toolkit is installed (i.e. C:\Program Files\Microsoft Deployment Toolkit\SCCM).
For step #5, create a new task sequence using the Create MDT Task Sequence wizard and you should see your newly created template:
Test it out to make sure it works and then share it with your coworkers, friends, local user group, etc.!
Originally posted on https://miketerrill.net/