Debug a Script

Debug Microsoft Operations Manager (MOM) scripts either from the local computer or a remote computer by using Microsoft Visual Studio®.NET. After the debugger is connected to the MOM service, you can step through scripts, set breakpoints, view the call stack, examine variables and objects, and use other debugging features in the Visual Studio® .NET development environment. You can debug scripts running on either the MOM Management Server computer or an agent computer.

Installing Remote Debugging Components

To support remote debugging, install the full set of Visual Studio® .NET debugging components on the computer running the script.

To install the remote debugging components on an agent computer or a Management Server

  1. From the Visual Studio® .NET CD or DVD, run Setup.
  2. In the Visual Studio .NET Setupwindow, click Remote Components Setup.
  3. On the Remote Component Setuppage, scroll to the Full Remote Debuggingsupport area, and then click Install Full.
  4. Click OKafter the installation is complete.

Enabling Debugging

The default settings on the MOM Management Server and agents do not support attaching a debugger to the running MOM scripts. You must enable debugging through the Windows registry.

For scripts that run on agent computers, enable debugging on each agent computer that you are debugging. If a script runs on the Management Server, enable debugging on the Management Server computer. This also allows you to debug agent scripts that are running on the Management Server.

To turn debugging on and specify which scripts to debug

  1. Run Windows Registry Editor (Regedit.exe).
  2. Navigate to the HKEY_LOCAL_MACHINE\SOFTWARE\Mission Critical Software\OnePointregistry key.
  3. Change the value of the DebugEnabledScriptsentry to specify the name of the script or scripts that you want to debug. Wildcard expressions are supported for this setting. If DebugEnabledScriptsdoes not already exist, create a new Stringentry for it.
  4. To enable debugging, change the value of the EnableActiveDebuggingentry to 1. If EnableActiveDebuggingdoes not already exist, create a new DWORDentry for it.

To disable debugging, change EnableActiveDebuggingto 0.

Note  Note   

Disable debugging after you have finished troubleshooting the problem. Enabling debugging will decrease performance, and other users could attach debuggers to the MOMService.exe process and lock threads for extended periods of time.

Attaching the Debugger to MOM

To attach the debugger to an agent or management server

  1. Start the Visual Studio .NET integrated development environment.
  2. On the Toolsmenu, click Debug Processes.
  3. In the Processesdialog box, in the Namebox, type the name of the computer running the scripts.
  4. In the Available Processeslist, select MOMService.exe, and then click Attach. Debug scripts on only one agent at a time.
  5. In the Attach to Processdialog box, from the list of program types to debug, select Script, and then click OK. Check boxes for all other program types should be cleared.
  6. In the Debugged Processeslist, select the MOMService.exeprocess, click Break, and then click Closeto save settings.
  7. Wait for a script matching the DebugEnabledScriptsregistry value to run.

To end the debugging session and detach from the MOM service, press Shift+F5.

Debugging the Script

The first script matching the name or wildcard pattern specified in the DebugEnabledScriptsregistry entry opens in Visual Studio® .NET. You can use the commands on the Debug menu. You can also view the data displayed in the various debugging windows, such as the Localswindow and the Call Stackwindow. For more information about debugging with Visual Studio® .NET, see the Visual Studio® .NET documentation.

When debugging MOM scripts, use the following guidelines: