You are browsing the archive for 2015 April.

SCOM: Automatically create management packs with PowerShell

10:56 am in operations manager, SCOM by Dieter Wijckmans

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:

  • Naming convention of the override management packs needed to be consistent
  • An override management pack needs to be created for all management packs introduced in the environment and for all stages in the DTAP process
  • An easy way has to be setup in the procedures for the engineer to create the override MP’s for all environments

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.

download (1)

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.

###
# 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()
}
}

Download the script from the technet gallery:

download-button-fertig11

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:

printscreen-8-04-2015 0001

Note:

  • Run this script preferable on a management server or a machine which has the SCOM console installed. If you don’t run this on a management server make sure to change the $managementserver variable to point to a valid up and running management server in the management group you would like to have the override packs created in.
  • Because we run this via PowerShell and not execute the work manually there are no “rogue” empty folders created in the monitoring view thus we are not clogging up our console view.

MVP 2015: Cloud and Datacenter Management

4:49 pm in Uncategorized by Dieter Wijckmans

 

printscreen-1-04-2015 0004

It’s very strange how time flies by so quickly… It has already been a year since I received my first MVP title and just a week a go I noticed I was up for renewal again…

Receiving the mail above always has something magical like new-year’s eve. A new year full of opportunities lies ahead to experience the true value of the MVP program. During the last year I’ve got to learn a lot of people in person which I knew already online out of the community, got to interact with the product team and took part in some really cool in depth discussions which really benefit the products I work with on a daily basis.

It’s nice to know where to go to if you have a problem with configuring something… And with that I’m not only referring to the MVP community but also the System Center community in general. It’s you out there who keep this community alive and I’m grateful I can contribute to it.

So in conclusion: I hope we’ll meet (again or for the first time) at an event or online and keep continue to spread the Sysctr love.