Exporting Task Sequences from ConfigMgr to plain xml files

In the last blog post I showed a script that would allow you to import a Task Sequence from an xml file as the ones being created by the Task Sequence monitoring script (see http://maikkoster.com/versioning-monitoring-sccm-task-sequences/ for details).

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:

  1. The ConfigMgr Module requires the ConfigMgr console to be installed. I pesonally like to be independent from this for „simpler“ or automated tasks.
  2. 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.

Find the full script at https://github.com/MaikKoster/ConfigMgr/blob/master/TaskSequence/Standalone/Export-TaskSequence.ps1

How to use it

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

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.

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.

In addition the script also supports the default WhatIf and Verbose parameters

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.

Standalone Version: https://github.com/MaikKoster/ConfigMgr/blob/master/TaskSequence/Standalone/Export-TaskSequence.ps1

„Module“ Version: https://github.com/MaikKoster/ConfigMgr/blob/master/TaskSequence/Export-TaskSequence.ps1

ConfigMgr Module: https://github.com/MaikKoster/ConfigMgr/blob/master/Module/ConfigMgr.psm1

 

Das könnte Dich auch interessieren...

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.