Friday, 2 November 2012

Using MDT Monitoring with Config Manager Task Sequences - PART 1

Wow, first post!

So, im not going to muck around with hellos, introductions etc etc. Lets get straight into it!

I've been pretty interested in MDT 2012s new monitoring feature, pretty useful feature straight out of the box. However, seems that this will only provide information on MDT Task Sequence steps. Great if you are solely using MDT for your deployments, not so useful if you are using MDT integrated with ConfigMgr, and your own custom ConfigMgr task sequences.
I wanted to find a way to monitor a Config Manager task sequence using the MDT monitoring web service, with no modifications whatsoever.

First of all, there is one big negative point with MDT monitoring, that is the fact that its not historical. It will tell you where your deployments are at at that point in time, but information around the past events isnt retained. In my opinion, this makes using it as your OSD monitoring solution a little flawed. Generally you will want historical info, the full picture of your OSDs as it were.

For this post I am going to go over how I got the MDT monitoring working for Config Manager task sequences. Future posts will describe how to use this process to get the info into your own monitoring solution.

So - Lets begin...

If you do not know how the MDT monitoring feature works, i would STRONGLY recommend you check out the MDT Monitoring Deep Dives by OSD guru Maik Koster.
Also check out MDT Monitoring Info
Troubleshooting MDT Monitoring both by MDT Master Michael Niehaus.

Done your background reading? Great!

SCCM Task sequences are not aware of the MDT monitoring service, meaning that every step being run is not actually communicating to the web service. That makes sense. The challenge is, how to monitor a running task sequence and pass info back to MDT?

The easiest way (IMO -if you see something easier definitely let me know via the comments) that I could see to do this was to monitor the current task sequence step. Every time the TS step changes, fire an event to the web service.
I did this by monitoring the  _SMSTSNextInstructionPointer TS variable. This contains a pointer to the current step. When the value of this changes, I fire off an event. See below for the script.


So essentially what we are doing here is :
  • Creating a GUID (unique identifier required to track a job)
  • Specifying the MDT event service name (this might not be needed if you have this in your customsettings.ini)
  • Comparing the value of _SMSTSNextInstructionPointer to its last value. If its different, running the CreateEvent method from ZTIUtility.vbs
  • Looping FOREVER...(or at least until a reboot :) )

There are a couple of things to be aware of here..

At present, a Toolkit Package/Gather needs to be run ahead of the monitoring starting. I am working on a way to get this running from step 1, will update this when that work is complete)
Everytime a reboot occurs, the monitoring needs to be restarted. (Again, i'm trying to find a way to autostart this to make it a bit more resilient)

The instructions for getting this working are below:
  1. Save above script (place this in the Scripts folder of your MDT package. Im using the name "ZTIMonitor.wsf"
  2. Edit your existing task sequence - place a new run command line step below your Use Toolkit/ Gather steps.
  3. The command line to run is : cmd /c START %scriptroot%\ZTIMonitor.wsf
  4. Copy this step to run after every reboot your TS performs.
  5. Save your TS
  6. Run an OSD, and you should see your monitoring events appearing in MDT Deployment Workbench once the monitoring step is hit.

This works very well for my test lab - usual stuff applies here about testing this yourself, i'm not responsible for any data loss , yadda yadda yadda. The blog name isn't poorlycoded for nothing ;) Please drop me a line if you want more info or things arent working as expected.

Thanks for reading!


  1. Nigel - thanks for your post on this. I'm actually trying to get this to work properly with no success. At the very basic level, I'm trying to test this with a USMT scanstate task sequence. As you can see, the below taken from my SMSTS.log file, the commands complete successfully. No errors!

    Executing command line: smsswd.exe /run: cmd /c START %SCRIPTROOT%\ZTIMonitor.wsf TSManager 1/17/2013 4:11:23 PM 3036 (0x0BDC)

    Successfully complete the action (Enable MDT Monitoring) with the exit win32 code 0

    I have placed a run line command after the Use Toolkit Package step taht executes the following command line as described "cmd /c START %SCRIPTROOT%\ZTIMonitor.wsf" The TS does not fail, appears to execute the script, however, when I go into the MDT workbench under Monitoring I don't see anything. Any suggestions?



  2. Hi Michael -

    Sorry for the late reply. First things first, have you stepped through the article here :

    To ensure your MDT Monitoring service is actually functioning as it should?

  3. I am having similar issue and I have ran through the MDT monitoring and that piece is working. If I use your CMD that you recommend it does same as Nigel mentioned then if I try to run as I do my other script with cscript.exe "%scriptroot%\ZTIMonitor.wsf" I get ZTIMonitor.wsf(3, 3) Microsoft VBScript compilation error: Expected Statement

  4. Cory,

    On line 2 you need to change the end form ">" to "/>"

    However, I now get memory errors.