Back in 2015 i was working on various custom management packs which required a lot of bespoke settings and configurations which were required amongst various projects and took it perhaps as a challenge to see if there was a way of speeding up the process. Not necessarily just about the speed of the production, but also the overall quality of the produced management pack.
We find a lot of SCOM administrators and management pack developers tend to refer to our own created management packs and tailor around those which is great and in fact i do so myself, but what if you are in a situation in which you need to create something or add in addition in something you may not already had in your management pack to begin with?
Here is where i had developed the earlier versions of the POC called the SCOM Management Pack Creator.
A demo of this solution can be seen here https://scomathon.com/coffee-break/custom-mp-creation-with-powershell
There have been various releases of this such as the ones below;
Management Pack fragments are brilliant ways in which you can take the XML code of a specific fragment which has been developed before in which the administrator can then replace with their own IDs & properties in which they need, and is also a great way of being able to then hold onto them when they become your next successful management pack which you can then model from.
Where the solution here is different is that what you find with fragments and your own management pack fragments, you are required to search and replace multiple IDs and this can be lengthy, especially when you have a lot of fragments, classes, IDs, references etc
Not to mention they are also case sensitive so that adds another level of complexity. Also bear in mind that base classes can be completely different which will have a knock on affect to class fragments and anywhere else which is referenced. So though this method is great to use you still need to have a fair on idea on how you will develop the management pack.
The solution i have here will not only create the MPX fragment but it will also use your IDs and base classes and build them straight away in a matter of seconds, a very similar mechanism you would see if you were to create a SCOM management pack from the Operations Manager console!
See below all of the components you can create for the Management Pack;
During the transition to the official release of this solution, new features and additions have been made along the way.
Below are a handful of brand new features to help enhance this solution.
I have spoken of this in the past when i released the 3.0 version but have to re-iterate its powers!
The power of this function is with in conjunction to completing management pack builds on different functions which accept a pipeline and also accept a parameter with pipeline property name.
For example this command has switches to obtain the following;
Once you have worked on the intellisense you can then pipeline into a command like specified below.
Note that this doesn't work with variables this will only work when you specify the entire path (quotes, no quotes or spaces) then the intellisense will kick in.
With the previous versions being very well received there have been many bugs which have been meaning to be fixed and rectified in order to provide a smoother and cleaner management pack building process.
Though this solution is used to provide flexibility as well as provide quality of building a custom management pack with speed, certain bugs can impact the speed and quality of the product as well as spending unnecessary time in trying to troubleshoot and look for reasons why your management pack cannot be built correctly.
Or even worse when imported into SCOM to find certain issues in various parts of the modules. Below is a list of bugs which have been corrected.
The Management Pack Creator solution can be found in the following link below.
https://irp-cdn.multiscreensite.com/c1f89e50/files/uploaded/SCOM%20Management%20Pack%20Creator%20-%2...
You can also download the instruction guide which also gives full reference to every function in which the module has in the same link below
https://irp-cdn.multiscreensite.com/c1f89e50/files/uploaded/SCOM%20Management%20Pack%20Creator%20-%2....
The solution is of a PowerShell Module which can be imported.
In order for this to be working perform the following;
You will require two pieces of software before you can do this;
Once created you should then end up with the screen below
Once the module is imported you can then use the other PowerShell Script which comes along with it which is the SCOM Management Pack form.
It contains all of the functions needed and required to build your SCOM management pack in which you can then replace the values on the switches to build the management pack you require.
Below is a screenshot of what the form looks like.
The first values you see are variables which create all of the fragment MPX files required for your management pack. As you can see in the example there are already two variables filled out for the Management Pack Name file and Class file.
Below are the lines for every single function required to build out your entire management whether you intend to use all of them or most of them you can look through them.
There are values pre-filled to give you an example of what to put down to create your fragments.
Few things you should know about this process for full completeness of understanding;
If there are any lines, functions you don't require for your management pack then simply put a "#" next to the line so it doesn't get action-ed during the script.
Once you have configured all the properties and configuration you require you can either execute the entire script, or you can stagger it line by line if you are looking to see the process develop piece where you can observe changes in the MPX files etc
From here you can now update the script with the location of your Management Pack project which normally resides in the source\repo
location of your user profile i.e. C:\Users\Administrator\Source\Repo\Test management Pack
When you run the script you should then see MPX files get created in these locations as seen below.
You can then right click the project folder in Visual Studios and then select to import and then select the MPX file so that it is now part of your Management Pack Project.
Whether you run the script before or after this you should see XML code populated, if running after you will see the XML code appear in real-time as seen below.
When finished with the management pack select the Build - Build Solution option in the toolbar above.
Another cool thing we all want to do is to be able to seal our management packs so they end up as a .mp extension as opposed to an unsealed .xml extension.
To do this you need to open up the developer command prompt for visual studios
which should be located in your Visual Studios folder in the start menu or installation folder.
Then run the following command
sn.exe -k C:\Key\MPKey.snk
Once created you can then go to the properties of your management pack project and select the build tab and where it displays a box for your encryption key point to the location where you created the key earlier and select it.
Now when you build your management pack it should now create a .mp management pack in the Bin\Debug folder of your project repository.
The solution will have disclaimers when building specific fragments to warn you of any references which you may require.
But just in case we will cover it in this section.
Say for example you want to create an InstanceGroup within your class, if you try to build you may perhaps experience an error such as this.
If you see this, it's due to a missing reference management pack which is required. Luckily when you install the VSAE authoring extensions it creates a folder which contains all of the management packs which you may need for this and has them categorised depending on the version of SCOM that you are using.
The best way around this is to perform the following;
You will need to specify the entire path so that when using switches such as