BLOG
How to Use VSAE to Create Your First Management Pack to Discover an App Using Its Registry Key
Gabriel Mora is a Software Developer at Infront Consulting. Connect with him on LinkedIn.
Creating a new Management Pack is not complicated—all you need to do is first install Visual Studio Authoring Extensions. This blog will walk you through how to create your first Management Pack in Systems Center Operations Manager, one that will discover apps by identifying their registry key.
Follow this link to download it and install the authoring extensions: https://www.microsoft.com/en-us/download/details.aspx?id=30169
Once that is complete, you can go ahead and open Visual Studio (in my case I have VS 2015) and create a new Visual Studio Project. Give it a name and a path location for the source files.
Since I’m using System Center Operations Manager 2016, I’ll choose that as my project target.
You have now created a new Management Pack! But don’t get too excited yet, this bad boy is still empty. There is no logic in there to discover or monitor anything.
Before we add the discovery, let’s take a look at what we can do from inside visual studio. Right click on the project name in the Solution Explorer and navigate to Properties.
Inside there you have a bunch of options available for you to customize your new Management Pack, including:
- Change the Management Pack Name and ID
- Determine if you would like to Auto-Increment on every new build (this saves you the trouble of having to manually change the MP version on the top)
- Determine if you want to configure the default management pack group for this project (this will be used for MP deployments or any tools capable of connecting to a Management Group)
- And—in my opinion one of THE most important things you can do to safeguard your MP project—choose to make a Sealed MP (this means that the logic information inside of MP cannot be opened easily by a third party—of course there are ways to do that, but that is another blog entry)
With that out of the way, let's go ahead and add the first piece of logic to Management Pack. This logic will discover a particular application using its Registry Key in a Windows Computer. We will see how easy it is to accomplish this goal.
Download and choose the Management Pack Fragments Library Pack created by the Almighty SCOM God Kevin Holman. Here is the download link: https://gallery.technet.microsoft.com/SCOM-Management-Pack-VSAE-2c506737
Once you download the file, create a new folder in the solution explorer. I will call my folder “Classes”:
Once that is done, import the MP fragment from the RAR file called “Class and Discovery Registry Key Exists.”
Kevin Holman was kind enough to provide this fragment. Inside it, he is clear that all we need to do to successfully discover is to just FIND and REPLACE. Yes, that is really all you have to do.
Replace in this fragment the following components with yours:
##CompanyID##
This is the abbreviation of your MP Namespace (in my case MyTestMP.Samples)
##AppName##
Is the name of the Application it will look for (in my case FakeApp)
##RegKeyPath##
When replacing you don’t need to add the HKEY_LOCAL_MACHINE because it is already hardcoded in SCOM, so just use SOFTWARE**App**.
This is the registry key path inside of the computer (in my case this will be HKEY_LOCAL_MACHINESOFTWAREFakeApp)
Save the MP, build it, and you are done! You have created a MP that will check for an application using the registry key.
Import the MP to SCOM and wait a couple of minutes for it to load.
Go to Monitoring >> Change Target and find the class you created:
You have now discovered dynamically all machines that contain that particular registry key!
You are now an MP Dev rookie! Congrats.