A script to backup a task sequence in System Center Configuration Manager (SCCM).
It can be run manually, but the idea is to use this script with a status filter rule in SCCM, that will trigger every time a task sequence is modified. If the modified task sequence is the same as the one we want to backup, it will be exported as an
xml-file and then imported again to the console. To keep track of version history we use a version number that will be added to the name of the xml-file as well as the imported task sequence.
(For detailed instructions, see the following blogpost (in Swedish): http://www.infogeek.se/guider/automatisk-backup-av-task-sequences-i-sccm)
- Save the script to a file folder on your SCCM Site Server, e.g. C:\Scripts.
- Whenever the script is run your task sequence will be exported to an xml-file. Create a folder to store these xml-files, e.g. C:\TSBackup.
- Whenever the script is run, the exported xml-file will also be imported again, so that you will have a backup of your task sequence handy inside the SCCM console. Create a folder where the task sequences will be stored, e.g. Backup.
- In your task sequence, add a "Set Task Sequence Variable"-step and call it "DeployVersion" or something similar. Use this step for versioning, so add a value of a version number.
- Create a status filter rule and specify Microsoft.ConfigurationManagement.exe as Component and 30001 as Message ID. Whenever a task sequence is modified the status filter rule will trigger.
- Create a "Run a program"-action in the status filter rule with the following command line:
C:\Windows\system32\cmd.exe /c start /B C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\Backup-SCCMTaskSequence.ps1 -SiteServer CM01 -TaskSequenceID S0100001 -ModifiedTaskSequenceID %msgis02 -BackupPath
C:\TSBackup -TSArchiveFolderName Backup -TSVersionStepName DeployVersion
Replace the values in the parameters with your actual values.
Example of result when using this solution: