Debugging OpsMgr Scripts


One of the great advantages of OpsMgr 2007 against MOM 2005 is that you can easily test OpsMgr 2007 scripts from the command prompt.


Just go to the C:\Program Files\System Center Operations Manager 2007\Health Service State and open a command prompt.


Type DIR /B /S *.vbs and you find all the scripts that are used on that specific agent. And if you have found your script to debug you can easily run it with cscript and see what happens.


But what if a scripts needs some parameters? Most of the time these are GUIDS and how do you find the right parameters?


A colleague of mine Dirk van Coeverden found an easy way to find these parameters.


Let’s Look at the Operational Database Space Free (%) Monitor.


image


This Monitor uses a vbscript GetOpsMgrDBPercentageFreeSpace.vbs which needs two parameters to work


image


So if we want to debug this script we need two parameters; DatabaseServerName and DatabaseName.


How do we find those parameters?


First we need to go to the Authoring Pane in the Opsmgr Console and find the monitor which runs this script.


image


Then we change the default timeout of the script to something smaller then the default with an override. Say 1 second.


image


Now we have to wait for this monitor to run again and hopefully see that the script timeouts because of the lower timeout settings. And if the script runs longer than the timeout period an event 21402 – Script ran longer than the timeout period will be created.


image


Now you can debug the script from the commandprompt with the correct parameters. Don’t forget to remove the overrides.


image

Comments (5)

  1. Anonymous says:

    Source: System Center Forum Today I was watching the latest recording of the January 2009 SCUG Meeting

  2. Anonymous says:

    keep in mind that most script have a few characters that are HTMLEncoded, therefore if you copy&past the script from within the XML you will have to do some modifications to let them run on the OS… for example

    "&" becomes "&"

    "$gt;" becomes ">"

    "$lt;" becomes "<"

    …etc etc…

  3. Anonymous says:

    Hi Daniele,

    Thanks for the info. Forgot to mention that.

    Regards,

    Stefan

Skip to main content