VSAE – Create a Management Pack for discovery

One of my clients wanted me to give him the right way to create Management Packs with VASE using Visual Studio.

The client used to create a Management Pack containing a class and discovery as well as a few monitors and rules, then, the client imports his Management Pack and starts modifying it with the SCOM console.

The problem starts when the client wants to edit his discovery, then he tries to import the Management Pack back to the Visual Studio and overwrites his changes.

The proper way to deal with Management Packs is, in my opinion, to create a Management Pack for discovery and a separate Management Pack for Monitoring.

In this article, I will demonstrate the creation of these Management Pack and Sealing the discovery Management Pack.

In this demo, I will use Kevin Holman’s MP Fragments.

I will start by creating a new Management Pack for discovery.

Open Visual Studio, create a new project

Then choose Management Pack of the desired SCOM version.

Now that we have an empty Management Pack lets start discovering our app. I am going to discover my SQL servers by searching for the “MSSQLSERVER” service, for that I will use the “Class.And.Discovery.Registry.KeyExists” Fragment.

I have created a folder for the class discovery and added the fragments. Rename it as needed.

Replace the fields, in my demo, I use the registry key of the mssqlserver service – SYSTEM\CurrentControlSet\Services\MSSQLSERVER

Now that we have finished creating our discovery, we can go ahead and discover more classes relating to our application or build the project. To be able to create monitors from the SCOM Console and target them on the class we have just created, we need to seal the Management Pack. In order to do so, go ahead and open the Developer PowerShell For Visual Studio.

When Opened, move to the desired folder (using “cd” command) and type “sn -k msopsmgr.snk” – you can replace “msopsmgr” to any filename related your organization.
click Enter, to create the key for sealing the Management Pack.
DON’T FORGET THE LOCATION OF THE KEY! – Save it in a place you will find it later on

Move back to Visual Studio, right-click our Management Pack and choose Properties.

Then, click on Build, tick the Generate Sealed and Signed Management Pack, change the field as needed and choose the snk file we have just created together.

Click on save (ctrl+S) and then build the project (ctrl+shift+b).

In the output pane, we should see Build 1 succeeded. Then all we have to do is to import our sealed discovery Management Pack to SCOM and wait for the magic to start.

Now every time when we do a build off the Management pack the management pack will be sealed with the generated key.

In the debug folder we will see the MP files, import the MP to SCOM using Console/PS.

Now when scoping at the class we have created in the Discovered Inventory in the Monitoring pane, we will see all of the SQL servers as expected.

Now that we have a class with the discovered object that is based on a seal Management Pack we can target any monitor from any management pack on this class or we can go ahead and create a new unsealed management pack using Visual Studio, just keep in mind to add the Discovery Management Pack we have created as a reference.