Hi All,

Hopefully this isn't too far off topic, but I'm trying to hack together a 
method to automatically capture a copy of our task sequences whenever they are 
modified for easy documentation and version control. Having some trouble and 
figured someone out there might be able to tell me what I'm doing wrong or 
provide a better solution all together.

So far I've been trying to combine the automagic task sequence documentor 
stylesheet from here:
http://blogs.technet.com/b/deploymentguys/archive/2009/02/20/update-to-the-tasksequence-documentor.aspx?PageIndex=1#pi36647=2

and the WMI event subscription functions to kick off a script Powershell script 
whenever the TS gets modified. I used the PowerEvents PS module by Trevor 
Sullivan (http://powerevents.codeplex.com/) to build the WMI filter/consumer 
and it kicks off the following command line:

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -executionpolicy 
unrestricted d:\Scripts\ExportPowershellTS.ps1 %TargetInstance.PackageID%


ExportPowershellTS.ps1 looks like this:

## Set a parameter for the package ID
param(
[string]$TSPkgID
)

## Import the SCCM Powershell Module
import-module "D:\Program Files\Microsoft Configuration 
Manager\AdminConsole\bin\configurationmanager.psd1"


## Change location to the SCCM site
set-location XXX:


## Gather the timestamp
$Timestamp = (Get-Date -Format 
s).Replace("/","-").Replace(":",".").Replace("T"," ")

## Gather the task sequence name property
$TSName = (Get-CMTaskSequence -TaskSequencePackageID "$TSPkgID" | select 
-ExpandProperty Name)

## Gather the XML for the actual task sequence steps
$TS = Get-CMTaskSequence -TaskSequencePackageID "$TSPkgID" | select 
-ExpandProperty Sequence

## Insert stylesheet to use on the top line of the task sequnce file
Write-Output '<?xml-stylesheet type="text/xsl" href="tsDocumentorv2.xsl"?>' | 
Out-File "D:\temp\$TSName $Timestamp.xml"

## Append task sequence Steps
Write-Output $TS | Out-File "D:\temp\$TSName $Timestamp.xml" -Append


So far it's half working, seems to be getting tripped up by the command line 
with the %TargetInstance.PackageID% variable. The variable isn't getting a 
value, so it's just creating a file with the style sheet info on the top line 
and the timestamp in the file name. It isn't able to gather the task sequence 
name or steps without that value.

Eventually I'm planning to have the file and stylesheet zipped up and uploaded 
to a TeamSite page for people to track the TS changes that were made.






________________________________

This message is intended for the sole use of the addressee, and may contain 
information that is privileged, confidential and exempt from disclosure under 
applicable law. If you are not the addressee you are hereby notified that you 
may not use, copy, disclose, or distribute to anyone the message or any 
information contained in the message. If you have received this message in 
error, please immediately advise the sender by reply email and delete this 
message.



Reply via email to