Friday, 12 March 2010

Showing the last error in an SCCM OSD Task Sequence

Any of you that use SCCM / Configuration Manager to deploy operating systems will know what a pain it is to trawl trough the log files to determine why a build failed. I wanted the end user to see why the build had failed and there didn't seem to be a built in way to do this so I created a script that parses the SMSTS.log file for the last error that occurred before the task sequence fails and show it to the end user.

We use a customised Microsoft Deployment Toolkit (MDT) task sequence to build our desktop PCs so the script gets called as the last step in the "Gather Logs and StateStore on Failure" group:

The script is called as "Run Command Line" step running "cscript.exe "%deployroot%\scripts\UWEShowBuildError.wsf"

and will show the something like this if an error occurs during the task sequence:

The script will also create a small log file recording this error UWEShowBuildError.log which ends up with the rest of task sequence logs (System32\CCM\LogFiles)

Download the script here.
(I use the pre-fix "UWE" on our scripts, variables, etc to distinguish them from the Microsoft scripts)