Authoring Custom Templates and Writing Custom UI in OpsMgr

Management pack authoring templates are a useful way to add additional monitoring on an as-needed basis. A great example is the TCP port wizard – it would make no sense to monitor every TCP port out of the box, so OpsMgr provides a wizard for adding ports on a case by case basis.

So what if you would like to modify how one of the existing templates works or create your own? There is no documentation available that I have found that describes how to do this so that is what I’m setting out to do in this article.

Creating a custom template involves two main components:

  • The template elements in a management pack. I’ve attached a working sample and added lots of comments so please have a look through.
  • A compiled UI screen written in managed code (c# in this case).

A word of warning: the authoring console does not support either of these components.

Here are the steps you can use to create your custom UI screen:

  1. Using Visual Studio, create a new class librarynewproj
  2. Delete the class1.cs file that gets created by default
  3. Add references to the necessary OpsMgr DLLs. You can find these in the C:\Program Files\System Center Operations Manager 2007\ folder as well as the SDKBinaries folder within that folder.refs
  4. Add a new User Control to the project named EventDetailsPageNewControl
  5. Double click on the user control to open the designer screen. Add your UI widgets from the toolbox. I’ve added two text boxes named txtEventID and txtEventSource.AddUI
  6. Open the code view of your user control and make the following changes by copying and pasting from the code that I’ve attached to the article:
    1. Add all the “using” statements
    2. Change the class to inherit from UIPage
    3. Add the SavePageConfig() and LoadPageConfig() methods
  7. Build the project
  8. Copy the DLL that you’ve just compiled to the OpsMgr program files folder.

Now you are ready to run your new template!

Import your management pack and go to the authoring templates. Your new template will show up in the list. When you run the wizard, your UI screen will allow the user to input values.


A note on how OpsMgr processes templates when you’re done with the wizard:

  • OpsMgr replaces $TemplateConfig/ConfigValue$ variables in the implementation section of the template with the user-provided values.
  • Merges the implementation section into the management pack that you specified on the first wizard screen.
  • Creates a <folder> for the template and puts every generated element in the folder using <folderitem>s. When you click on your template after running the wizard, OpsMgr uses this folder system to display previous output of the template. This is also how it knows what to delete if you delete template output. A side effect of this is that it is assumed that you will create elements with unique IDs for each run of the template. If you create non-unique elements, OpsMgr will effectively delete all runs of the template when any single run is deleted.

The sample UIPage I’ve attached barely scratches the surface of what is possible. Some fodder for future articles or your own exploration:

  • There is a built-in SDK connection available in the UIPage so you can populate drop-down lists with monitored computers for example
  • The UIPage has various properties that give you the context in which it is running such as a reference to the template itself
  • You can handle the user editing your template as well as just creating new ones
  • You can create custom UI for other workflows such as rules, monitors ,etc

More Resources:

See Part II : Custom Template UIPage Code Walkthrough

Download the Example => Template Test Zip File

11 thoughts on “Authoring Custom Templates and Writing Custom UI in OpsMgr

  1. Profile photo of Stefan KoellStefan Koell

    Finally someone came forward and covers this topic as well. Thanks for that, Joel! Hopefully we will see many extensions based on your how-to.

  2. Profile photo of DSDS

    Hi Joel,

    Thanks a lot for this article !!

    Requesting to help me on below issue I am stuck.

    I have developed my own management pack using VSAE tool ( usingVSAE inside  Visual Studio 2013 Ultimate version).

    Now when I am trying to integrate the same code (from TemplateTest.xml) into my own management pack while adding new item as ManagementPackFragmnet, facing build error as ID required for FolderItem.

    <FolderItem ElementID=”TemplateTest.UIPageLibrary” Folder=”TemplateTest.Template.Folder” ID=”Template.Template.FolderItem” />

    While providing ID (above code in bold letters), I am successfully able to build solution and  import MP using VSAE tool itself.

    But while going ahead, when I tried to “add monitoring wizard” in SCOM 2012 facing error as below..

    “Microsoft.EnterpriseManagement.Common.ObjectNotFoundException: An object of class ManagementPackResource with ID ee1821e0-9983-afc7-4a7a-e42990166d74 was not found.”

    But when I build the solution and manually remove this ID from my generated Managemetn pack xml file from bin\debug folder and then import this xml MP in SCOM insted using VSAE tool, functionality works fine for me.

    But as I am having dependancy with VSAE, please help me to resolve this issue.

    Also in this scenario we are using monitor, but I have to create one template for discovering devices and authoring purpose on the basis of IPAddress, UserName and Password fields. Any points will be appreciated.

    Thanking you in anticipation.

    Awaiting for your replay.






Leave a Reply