Recently I was asked by a customer to make a multi tenant SCOM setup with different environments. There are several ways of doing this with connected management groups and all but I opted to keep one management group and make the separation there as this was the best fit for the client. I’m not saying that this is the best fit everywhere but for this particular case it was.
They have a very strict DTAP (Development – Test – Acceptance – Production) lifecycle for their software release model so this should be reflected in the SCOM model as well making things a little bit more complicated.
So to sum up the requirements:
You could create a procedure to instruct the engineer to create the management packs as part of implementing a new management pack in the environment but this creates tedious repetitive work which will lead to errors or will just be forgotten.
That’s why I’ve automated the process of creating these override management packs with PowerShell following the naming convention which is in affect in your company.
[xml]
###
# This PowerShell script will create override management packs for all management packs which fall into a specific
# patern documented in $orgmanagementpackname
# Usage: CreateManagementPack.ps1
# Note: You can change the parameters below and pass them with the command if desired.
# Based on the script of: Russ Slaten
# http://blogs.msdn.com/b/rslaten/archive/2013/05/09/creating-management-packs-in-scom-2012-with-powershell.aspx
# Updated the script to create a management pack for all environments in the array $environments
###
###
# Declaration of parameters
###
$ManagementServer = "localhost"
$orgmanagementpackname = "microsoft.windows.server.2012*"
$Environments = "P", "A", "D", "T"
###
# Find the managementpacks which fit the filter documented in $orgmanagementpackname
###
$managementpacks = Get-SCOMManagementPack |where{$_.Name -like "*$orgManagementPackName*"} | select name
Foreach ($managementpackocc in $managementpacks)
{
$name = $managementpackocc.name
}
$name
###
# For all managementpacks in array managementpacks create a new override management pack with a correct naming convention
# and 1 override management pack per environment
###
Foreach ($env in $environments)
{
# fill in the name of the management packs
$ManagementPackID = "*Fill in company name here (no spaces!)*."+$env+".$managementpackocc"+"."+"overrides"
$ManagementPackName = "*Fill in company name here*: "+$env+" : "+$managementpackname+" overrides"
Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
$MG = New-Object Microsoft.EnterpriseManagement.ManagementGroup($ManagementServer)
$MPStore = New-Object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackFileStore
$MP = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPack($ManagementPackID, $ManagementPackName, (New-Object Version(1, 0, 0)), $MPStore)
$MG.ImportManagementPack($MP)
$MP = $MG.GetManagementPacks($ManagementPackID)[0]
$MP.DisplayName = $ManagementPackName
$MP.Description = "Auto Generated Management Pack"
$MP.AcceptChanges()
}
}
[/xml]
Download the script from the technet gallery:
This script will actually find all the management packs which fit the input mask in $orgmanagementpackname and create for each of these management packs an override management pack following the naming in $ManagementPackID and $ManagementPAckName.
This results in the following structure:
Note: