Creating your own MP store – Part 3: Automating most of that stuff


This is part three of my little “MP store” series. Please read Part 1 and Part 2 to understand my thoughts behind the following scripts.

Now it is time to automate at least most of this MP store stuff.

Creating a MP store folder structure

Ok, this is lame, but as I am lazy I wrote a small function new-mpstorefolderstructure (see attached helper function) which will do all the work:
You call the function with the base folder name and optionally with some Management Group names…

… and it will create the correct folder structure:

Downloading and reporting on MPs from MP Catalog and MP Wiki

Based on scripts from Stanislav Zhelyazkov, Damian Flynn, Cameron Fuller and Tao Yang (see full credits inside of the script) I created my own universal download script SCOM-MP-GetCurrentMSMPVersion.ps1 (you can find it on Technet Gallery) which provides this functionality:

  • Creating a CSV (and optional Excel) report of all current MPs on the catalog and Wiki
    This part of the script will create a CSV subfolder in the store with all reports:

    One of the XL files look like that and can be used as a reference:
  • Download all files currently available on the catalog
    It will create a subfolder in the MP store each time you will run the script, (because there is no other version information available) including an error log file:
  • Download all files currently available on the MP Wiki
    This function will create a subfolder called _WIKI-DOWNLOAD in the MP store folde and creates a versioned subfolder for every MP currently available on the MP WIKI page. The Picture Shows the MBAM MP:

With this script you can check the most current Microsoft MP versions (by looking at the CSV/Excel reports) and can optionally download all currently available Microsoft MPs at least as raw data. This is how the MP store looks like after running the script:

Extracting, sorting and archiving of raw MP data into the correct folder structure

Ok, now that we have downloaded the MPs in some kind of Format: Most probably we will have a MSI and maybe a MP Guide as a Word document. How do I sort and put that MP away into the right folder structure in my MP store?
You can do that manually by installing the MSI and moving all files around but as I said: I like automation 🙂

I wrote a script called SCOM-MP-ExtractSortArchive.ps1 (available on TechnetGallery) that provides this functionality:

  • Extracts all files from a MSI file
  • Converts all .MP/.MPB files to .XML (for later analysis or comparison purposes)
  • Extracts all content of a .MPB file (for later analysis purposes as well)
  • Copies all files into the correct sub folders in my MP store
  • Sort and put the MP away into the right folder
  • Archives old version if necessary

Let’s see the script in action working with an empty MP store (see my basic MP store folder structure above).
In this example I will demo this script without using the MP catalog or Wiki download to show, that it is independent of these folders.

I will pick the current SQL MP as an example and copy it together with the MP guide into a source folder:

Now I will call the script with the name of the source folder, a staging folder (can be deleted later on), the MP store root folder and a vendor name. In most cases the vendor will be Microsoft, but as it is hard to gather the correct vendor name from the information stored in a MP file, I require this name as a script parameter:

PS C:\Temp> .\SCOM-MP-ExtractSortArchive.ps1 -MPSourceFolder C:\Temp\Source -MPStagingRootFolder C:\Temp\StagingRoot -MPStoreRootFolder C:\Demo\MP-Store -Vendor Microsoft

The script will then perform the actions explained above step-by-step…

It has created the correct folder structure and placed the MP files …

… and the converted XML files (and all other files as well) into the right folder structure:

This script will work with

  • MPs from Microsoft, 3rd party vendors, custom or community MPs
  • .XML/.MP/.MPB and .MSI files

as long as you are using the right MP store folder structure.

IMPORTANT NOTES

  • This script should be executed with one MP at a time (so first SQL, then IIS and so on).
  • It will only run fine, when the MSI accepts custom installation directories. Unfortunately there are few MSI files available, which have a fixed installation path written into the MSI file. For those MPs the script will not detect the correct installation path thus cannot find the extracted MP files.

If you do this for all you Microsoft, custom, community and 3rd party MP you will get a MP store which could look like this:

Creating a reference folder with all current MPs from the MP store

This part is easy again. I created a tiny function get-scommostcurrentmpsfromstore (see attached helper function) which walks through all vendor folders and returns all current .mp/.mpb files into the reference folder.

Before you run the script your reference folder is empty:

Then you call the function with the MP store path:
PS> get-scommostcurrentmpsfromstore -MPStoreRootFolderPath D:\MP-Store -Verbose

And it fills the folder with all MPs from Microsoft, 3rd party vendors and community MPs:

Summary

Congratulations if you made it up to this point 🙂

I want to thank Cameron, Stanislav, Michael, Damian, Tao and all other community members for their great work and to shed light on this underestimated topic.
I hope I could show you in this little blog series

  • why it is important to create your own MP store and
  • how you can do that

My described approach is not the only way of doing it and I do not claim to have found the philosopher’s stone. It has also pitfalls and is far from being a 100% complete and automated solution. But it works for me so far and hopefully gives you at least some ideas on how you can do it in your own environment.

I really like to hear feedback from all of you. Do you find that information useful? 
Depending on that feedback I will continue writing about storing and handling Management Packs.

Part3-helper-functions.ps1

Comments (1)
  1. Anonymous says:

    Have you checked your Management Groups lately if they contain the most current sealed Management Packs

Comments are closed.

Skip to main content