As this covered a need that I basically created myself by publishing a script that creates those xml files, you might wonder why anyone would need a custom script to export Task Sequences, if there is already the Export-CMTaskSequence CmdLet from the ConfigMgr module?

Well, there are two major reasons for me:

The ConfigMgr Module requires the ConfigMgr console to be installed. I pesonally like to be independent from this for “simpler” or automated tasks.

The export from the ConfigMgr console or the PowerShell Module is a zipped file, rather than a plain xml file. It can contain referenced packages, applications, etc. While this will be a huge benefit for certain, probably most, scenarios, it’s kind of cumbersome, if you need to keep it simple.

Long story short, I actually need to have this functionality, so feel free to use it as well.

How to use it

The script comes with (hopefully) proper documentation. So calling the default

Get-Help .\Export-TaskSequence.ps1 -detailed

should give you a good start.

First, it requires the Path where the Task Sequences shall be exported to. In addition you need to supply the ID (Task Sequence PackageID) or the Name of the Task Sequence that you would like to have exported. You can also supply multiple PackageIDs or Names.

.\Export-TaskSequence.ps1 -Path "%Temp%\Export" -ID "TST00001"

On default, it will create a subfolder per Task Sequence and use the PackageID as the name with a 3-digit suffix. If you would like to change this behaviour, use the Filename parameter, which allows three different placeholders to be used.

#ID : which will be replaced with the PackageID of the exported Task Sequence Package

#Name : which will be replaced with the Name of the exported Task Sequence Package

#0, #00, #000, … : which will be replaced with an incrementing number based on the same name

The default value for the Filename parameter is “#ID\#ID_#000.xml”. If you use a pattern without incrementing number, you should also supply the Force parameter, otherwise the script wouldn’t overwrite an existing file:

As most of my other scripts that are targeted for automated operations as well, it will be quiet and doesn’t output anything beside errors. However especially if exporting several Task Sequences or working over a slow WAN connection, it might be helpful to show the current progress. For this, you can supply the ShowProgress parameter.

Finally, by adding the PassThru parameter, the script will output the path to each exported file, so it can be used for further processing.

There are two versions of this script available. The one referenced above is a standalone version, created by the script from my recent post “Creating standalone PowerShell scripts – automatically merging module components into scripts”. The “real” script is referencing a SCCM (ConfigMgr) module that I’ve published at Github as well. As I regularly apply changes to this module, it might be better to use the standalone version as this will be updated every time there has been a change on a function used by it. But that’s up to you.