jump to navigation

Capturing Debug Information from Client Scripts (New tool) November 5, 2009

Posted by keithga in Uncategorized.
trackback

(New for MDT 2010)

From my previous post, I wrote that for MDT 2010, there is a new common command line parameter called “/debugcapture”. This command line parameter will disable the common MDT error handling functions and let any errors echo out to the console.

This is great when calling MDT Client scripts directly from cscript.exe, however it is not helpful when calling from within a MDT Litetouch Task Sequence. Since the MDT 2010 Litetouch Stand Alone Task Sequencer does not capture the output from the client scripts for logging.

Introducing ZTICscript

To solve this problem, I developed a wrapper script called ZTICScript. It will call a client script with the new /debugcapture flag, capture any error output, and copy the error lines to the standard bdd.log system.

It’s been really great when developing new client scripts that may have errors, and speeds up the identification of bad code. As I mentioned in my earlier post, using the information captured with the /debugcapture flag, I can identify the line number and sometimes the variable name of of any errors.

Another cool thing about getting the output from /debugcapture rather than from the default error handler, is that it can also capture compile time errors. For example, if you have written a script with an unterminated string:

wscript.echo "Unterminated string

These errors are nasty, since the bdd.log will not display any errors from the script. Sometimes you may need to go into the smsts.log file to find out which script it was executing when it failed.

Step 1 – Modify your TS.xml file.

Open up your Ts.xml file ( %deployroot%\control\<dir>\ts.xml ), or ( %programfiles%\microsoft deployment toolkit\templates\client.xml ), and replace every instance of

cscript.exe

with

cmd.exe /c %scriptroot%\zticscript.cmd

For example, if you are trying to capture debugging information from the ZTINextPhase.wsf script, the command line should look like (single line):

cmd.exe /c %scriptroot%\zticscript.cmd
"%SCRIPTROOT%\ZTINextPhase.wsf"

Step 2 – Create ZTICScript.cmd and ZTICScript_log.wsf.

Get the script files from here, and copy them to your %DeployRoot%\script directory.

That’s it!

Now, if there are any errors in your script that would normally be caught by the standard MDT Exception Handler, they will instead be output to the console and piped to the bdd.log file. Very helpful in scenarios where normal bdd.log files are not returning the correct information.

Please note, that for some reason, I have been unable to get this script to wrap around LTISysprep.wsf 100% of the time. I just haven’t had the time to debug what’s happening. I think it may have to do with the heavy resource requirements of sysprep.exe.

Attachments:

http://cid-5407b03614346a99.office.live.com/self.aspx/Blog/ZTICScript.zip

Keith

Keith Garner is a Deployment Specialist with Xtreme Consulting Group
Advertisements
%d bloggers like this: