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.
This Monitor uses a vbscript GetOpsMgrDBPercentageFreeSpace.vbs which needs two parameters to work
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.
Then we change the default timeout of the script to something smaller then the default with an override. Say 1 second.
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.
Now you can debug the script from the commandprompt with the correct parameters. Don’t forget to remove the overrides.