I guess everyone uses the report showing how fare along a Task Sequence actually is, or if one of the steps has failed. But sometimes this report disappears after the TS finishes, so wouldn’t it be nice to always have it available afterword to see it one or more steps have failed, or to evaluate if an option acts like expected..
Well with a little help from one of my collages (Claus Codam) I created this routine to have that available, in by LOGS folder, and here is how.
1. Create a new user to use for reporting (in this example the account will be CM-Report), or choose an existing one.
2. Grant that user reporting rights and modify rights to the LOG share.
To Grant reporting rights, first log on to the site server holding the Reporting Point Role. Go to “Local Users and Groups” – “Groups”, open “SMS Reporting Users” and add the user to the Group.
From within the Config.Mgr console, navigate to “Security Rights” – “Rights” and grant the new (or existing) user Read permissions on the Report Class.
Create a folder to hold the logs, and grant the user modify permissions to that folder.
3. Add the actual script that will create the report , to a package, to make it available during deployment.
' //*************************************************************************** ' // ***** Script Header ***** ' // ' // Solution: File copy relative to script location ' // File: TSReport.vbs ' // Author: Michael Petersen, Coretech A/S. [email protected] ' // Purpose: Create a hardcopy af the TS progress report aqnd place it on a share. ' // Usage: Run as last step in a TaskSequece. ' // ' // Syntax: cscript.exe TSReport.vbs %SLShare% %_SMSTSAdvertID% %_SMSTSMachineName% ' // ' // %SLShare% must be defined or replased with full path to log share. ' // ' // ReportingPoint and RedortID must be changed to match environment. ' // ' // CORETECH A/S History: ' // 1.0.0 MIP 21/01/2011 Created initial version. ' // Customer History: ' // ' // ***** End Header ***** ' //*************************************************************************** Set Fso = createobject ("scripting.filesystemobject") Set args = WScript.Arguments ' ReportingPoint and RedortID must be changed to match environment. ReportingPoint = "http://CM01:80/SMSReporting_C01" ReportID = "143" 'History - Specific task sequence advertisements run on a specific computer If args.Count <> 3 Then WScript.Echo "Please provide 3 arguments: SLShare _SMSTSAdvertID OSDComputername" WScript.Quit(1) End If SlShare = args.Item(0) AdvertID = args.Item(1) ComputerName = args.Item(2) http = ReportingPoint &"/Report.asp?ReportID=" &ReportID & "&AdvertID=" &AdvertID & "&ComputerName=" &ComputerName TimeStamp = Right("0" & Day(Now), 2) & "-" & Right("0"& Month(Now), 2) & "_" & Right("0" & Hour(Now), 2) & "."& Right("0" & Minute(Now), 2) If Fso.FolderExists(SlShare & "\" & computerName) then file = SlShare & "\" & computerName & "\" & computerName & "_" & TimeStamp & ".html" else Fso.CreateFolder(SlShare & "\" & computerName) file = SlShare & "\" & computerName & "\" & computerName & "_" & TimeStamp & ".html" End IF WScript.Echo http WScript.Echo file SET xmlhttp = createobject("msxml2.xmlhttp.3.0") xmlhttp.open "get", http, false, user, pass xmlhttp.send Set newfile = fso.createtextfile(file, true) newfile.write (xmlhttp.responseText) newfile.close
4. Modify the script to support your own environment, by changing the ReportingPoint and ReportID variables.
The ReportID should be 143 as it is in the script, but in cases where config.mgr has been upgraded from previous versions, it might have changed. To find the correct ID number, open “Reporting” – “Reports” in Config.Mgr and look for “History – Specific task sequence advertisements run on a specific computer”
The ReportingPoint value can be found by opening the ConfigMgr reporting point Role
Once the changes have been mad, remember to update your DP.
5. Add steps to your TS to run the script.
Basically all you need to do is add a ”Run Command Line” step, as the last step in your TS, and run it as the report user created earlier. The syntax for running the script is as follows:
cscript.exe TSReport.vbs %SLShare% %_SMSTSAdvertID% %_SMSTSMachineName%
SLShare must of cause be defined prior to running this step, or the share path can be typed in instead, AdvertID and MachineName are picked up automatically by the TS, although you might want to change _SMSTSMachineName to OSDComputerName, depending on how you do your installation.
The reason these variables are not picked up by the script is because they are not available when running the script under a different account.
In the screenshot beneath you will notice that I put in a step to have the TS wait for two minutes just before running the reporting step. This is because it takes a little while before the info on each steps are actually reported back to the DB.
That’s it. You will now get a report like this in your LOGS folder, with the same layout as the normal report.
[download id=”27″]
Hi Michael,
Can you show me a screenshot of the TS step “wait for minute” and “Set Log Share Path” like you have done it in the clip_image006?
Thank you
Regards
Matthew
Hi Michael,
I’ve configured the steps as you showed it but I keep getting a error messages that says, “failed to get token information” and “Failed to run the action: Create TS Report.
Incorrect function. (Error: 00000001; Source: Windows)”.
Any idea of what is the issue?
Thanks in advanced!
Great article…
[…]The info talked about in the report are several of the most beneficial out there […]…
Thanks for the script. It’s great and it has solved my 3 months struggle to keep the OSD reports. In addition I have faced two issues with the script ,which i have resolved.
1.I have provided wrong URL , which results in an error with xmlhttp function.
2.If the text stream is huge the html file will be empty without recording anything and the write function will fail with an error. TristateValue should be set to -1 to write more data to the file at a single go.
[…] view source […]