Create Overrides in Bulk – Powershell Script

Important: Consider this script as BETA! I will not take responsibility for any damage this script might cause due to unforseen behaviour.

NOTE: I will rephrase this and add an Example with shiny screenshots once I find time for it.

So,

how, what and why would I write this?

Why?

I had several reasons but basically there is nothing more boring than creating overrides for Management Packs one by one. It’s a time consuming, mind-numbing process that I prefer to solve by running a script.

And since I was already planning it, I thought I’d create a very generic one.

Example:

We only react to alerts that have a High Priority. So, when we import a new Management Pack like the SQL Management Pack we’d have to override the Priority of Alerts one by one until the ones we don’t want to see are gone.

So I thought: Instead of doing this over and over for each Management Pack we just pre-override the Alerts to Medium and only activate the ones we really want to see.

How:

In the script you can find attached to this Blog you see the following Properties at the Top:

- OverrideMPDisplayName (Display Name of the MP in which you store the Overrides. Only alpha-numerical)

- FilePath (Folder in which you drop the Management Pack)

- MPNames (Name of an MP or a list of names separated by a semicolon ; )

- OverridePropertyName (Name of the Property you want to Override)

- OverrideValue (Value for the Override)

- RootManagementServer (name of the RMS)

Step 1: Loading/Creating the Override Management Pack

I decided to write the Management Pack to some folder instead of writing it directly into the Operations Manager.

So what I do is, I take the OverrideMPDisplayName and create an MPName (Removing Spaces) for it. I then check if it already exists in the folder you configured in FilePath.

In case it does, I load it, in case it doesn’t, I create a new one. So, if you want to create overrides for various values you can just use the same Target MP over and over.

Step 2: Creating Overrides for each Management Pack

I load each Management Pack you provided from the RMS and check if it’s sealed, if it’s not, I can’t create an Override for it and skip it.

If everything is fine, I add a Reference to the currently processed MP in the Overrides MP.

I then iterate through each rule/monitor and check if the OverridePropertyName you provided is overrideable on it. If yes, I create an Override, otherwise I skip it.

Step 3: Save the Management Pack

When everything is finished, I save the Management Pack to your Filepath with the MPName I created for it. It’s the Displayname without spaces, file ending is .xml.

Note:  I tested this with the Exchange 2010 Management Pack and when it says “Writing Management Pack…” it will stay there for quite some time. Actually, it takes ages. It has to verify each Override first, otherwise it won’t let you save the MP (that’s per default).

BulkDisabler

12 thoughts on “Create Overrides in Bulk – Powershell Script

  1. Avatar of Fabrice GASNIERFabrice GASNIER

    Well it was almost what I was searching for, but as I am a total Rookie in PShell I need you to troubleshot my little changes.

    My goal was to rise up the alertpriority, so I changed the first lines as

    $OverrideMPDisplayName = "AD_2008_Alert-High"

    $FilePath = "E:\temp\MP\MPAD"

    $MPNames = "Microsoft.Windows.Server.AD.2008.Monitoring"

    $OverridePropertyName = "AlertPriority"

    $OverrideValue = "High"

    but when i ran the script, it gets many errors like :

    Error in function Load-OperationsManagerEnvironment #1 : Exception calling .ctor with 2 argument(s): The ManagementPack parameter to this constructor cannot be null.

    What is this .ctor thing ???

  2. Avatar of Andreas ZuckerhutAndreas Zuckerhut Post author

    I guess you ran into the same issue as Fabrice, you used a "-" sign or something else in the Displayname? That will cause issues, please only use alphanumerical chars and "_" and ".", anything else will cause trouble.

  3. Avatar of Robert HenryRobert Henry

    Love the script. Have used it several times, although the background colors make the output nearly unreadable in Powershell ISE so I stripped those out. :)

  4. Avatar of jk567jk567

    I”m getting an error validating the override mp..anyone run into this?

    Exception calling “AcceptChanges” with “0″ argument(s): “Failed to validate item: Criticals_To_warns_Exchange_CAS.Over
    ride.Monitor_Microsoft.Exchange2007.DependencyMonitor.CASToOWA_Property_Severity_Value_1″
    At line:38 char:98
    + … olor DarkBlue; $Script:OverrideMP.AcceptChanges(); $Script:MPWriter.WriteManagem …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ManagementPackException

  5. Avatar of jk567jk567

    since I wasn’t trying to override, monitors but rules only (got monitors done with another script), i commented out line 62 and the script ran successfully.

Leave a Reply