Like many organizations out there, we have had a need to document our ConfigMgr 2012 task sequences. There are a few ways to do this, but I prefer the Task Sequence Documentor v2.
This is a very simple tool that uses the task sequence XML and a formatting xsl file to display a HTML page in Internet Explorer. Throw a nice PowerShell wrapper around it and you have an automated documentation method!
Kudos to The Deployment Guys for putting this together, and Benjamin McConnell and Chrispy in the comments section for the PowerShell reference!
The xsl file
By default, the xsl file gives you a nice old 90’s style format.
I am no web design expert, but I do like to segregate the child items with a border.
Just edit line 30 and 36 to add a little border. Add the border-color and set border=’1′.
1 |
TD.step { background-color:beige; border-color:black } |
1 |
<TABLE border='1' cellpadding='2' cellspacing ='0' style='font: 9px arial;border-width:0px;border-spacing:0px;border-style:none' width="100%" > |
This gives a little better output. Feel free to edit as necessary to tailor to your needs.
The script
- Must have the ConfigMgr 2012 Console installed
- Must run with PowerShell x86
- Must run with PowerShell 3.0+
- Must have tsDocumentorv2.xsl in the script root
- Lines to edit
- Line 1 – $sitecode – ConfigMgr site code
- Line 4 – $tsbackup – Path to backup to
- Line 41 – Export-TaskSequences -filter “*TaskSequenceNameHere*”
- Saves xml and xsl file to Backup_MMDDYYYY_HHMMSS
This script is a little rough around the edges, but it can be ran on a schedule to backup the task sequences you need.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
$sitecode = "PRI" $date = Get-Date -UFormat %m%d%Y_%H%M%S $tsbackup = "\\server\share\Backup_$date\" if ([IntPtr]::size -ne 4) { write-error "This script must be ran with 32-bit PowerShell." } else { $CMModule = 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' if ($CMModule) { New-Item $tsbackup -ItemType directory | out-null $xsl = (Get-ChildItem $psscriptroot -File tsDocumentorv2.xsl).FullName Copy-Item $xsl -Destination $tsbackup -Verbose function Export-TaskSequences { param ( $filter ) Import-Module $CMModule Set-Location $sitecode":" $tasksequences = Get-CMTaskSequence -Name $filter foreach ($ts in $tasksequences) { $tsname = $ts.Name write-host "`nTask Sequence:"$tsname $tspathxml = $tsbackup + "$tsname.xml" write-host "File Path:"$tspathxml Set-Location "c:\" Write-Output '<?xml-stylesheet type="text/xsl" href="tsDocumentorv2.xsl"?>' | Out-File $tspathxml $ts.Sequence | Out-File $tspathxml -Append } } Export-TaskSequences -filter "Windows*" } else { write-error "Please install the Configuration Manager 2012 console first!" } } |
Running it!
To view the documented task sequence you need to open the exported XML in Internet Explorer. When you open it, you will get prompted. The prompt is different for each version of IE, but on IE11 you get this.
Enjoy!
Being able to document Task Sequences is a handy thing, but doing it manually is incredibly tedious, error prone, and likely to miss details.
This is excellent!!
Thanks
Me again.
It appears that the script will fail with any task sequences that have a forward slash (/) in name. I presume there are a number of characters which will do like wise:
@ ” * ? \ / | : )
Don’t suppose you want to amend you script to ignore those, or replace with an underscore or something?
Yeah that shouldn’t be too hard Mike, keep an eye out for an update
Hello Daniel
Thanks a lor for your work.
I would like to ask you, I don’t understand very well how I can send to Task Sequense my variables, is it possible send it from the same script?
Thansk George. This script is meant to be ran outside of a running task sequence, and really is not related to what you are trying to do.
I would recommend reviewing Collection variables, Gather (if you integrate with MDT), or some other custom scripts.
https://www.systemcenterdudes.com/collection-variables-task-sequence/
http://deploymentresearch.com/Research/Post/348/Save-time-and-avoid-pain-Create-a-MDT-simulation-environment
http://powershelldistrict.com/how-to-read-and-write-sccm-task-sequence-variables-with-powershell/
http://mikewu.org/sccm/add-custom-task-sequence-variables-read-powershell/
http://www.potentengineer.com/using-powershell-to-set-osd-task-sequence-variables/
Good luck!
Brilliant mate… thanks !
I’ve been using this method for years but with the ability to run a task sequence from within a task sequence the child task sequence steps aren’t being or even being referenced. Any ideas?
Ah, unfortunately this method only parses the XML of the task sequence you are targeting.
The good news is I have a presentation in May at MMS 2020 about using the native PowerShell cmdlets to document your task sequences. It will include nested task sequences!
Can you share the source?
Due to COVID-19, MMS was rescheduled for late July. Will post some updates after that time.