Tuesday, February 21, 2012

SCOM 2012 - Quick Script to Backup your Unsealed Management Packs

Just a quick post to add a modification to a script that's been doing the rounds within the OpsMgr world for the last few years.

There's a management pack available from within the SCOM community that automates the export of your unsealed management packs (which of course contain all of your bespoke customisations and overrides). You can download the management pack for SCOM 2007 from SystemCenterCentral.com here.

This is an excellent tool for maintaing your SCOM 2007 environment, the problem now though is that it won't work with the new and soon to be released System Center 2012 Operations Manager (SCOM2012).

Update January 2013: Since I originally posted this, the System Center community has come up trumps again and a few months back delivered the SCOM 2012 release of this management pack. The new management pack was written by Pete Zerger, Neale Brown, Derek Harkin and Tommy Gunn and can be downloaded from the SystemCenterCentral.com site for free here. As was/is the case with the SCOM 2007 release, this management pack is ESSENTIAL to any SCOM administrator/consultant's toolkit and should be deployed as soon as possible to ensure quick backup and recovery of your unsealed management packs.

This is because of some changes to the Powershell commands that SCOM 2012 uses in comparison to SCOM 2007 R2.

I've taken a small piece of the powershell script from that management pack and made some minor changes to the code to reflect the new 2012 Powershell commands.

Here it is:

$all_mps = get-scmanagementpack
foreach($mp in $all_mps)
{
export-scmanagementpack -managementpack $mp -path "C:\MPBackups"
}

The small difference in the code above in comparison to the old code is that the 'get-managementpack' and 'export-managementpack' commands have been modified in SCOM 2012 to become 'get-scmanagementpack'' and 'export-scmanagementpack'

The above script will first unseal all of your sealed management packs and export them along with the already unsealed ones to a folder called 'C:\MPBackups' on your server.

If you want a script that will simply backup the unsealed management packs only, then use the following (this one will be what most people will probably want to use):

Get-SCOMManagementPack | where {$_.Sealed -eq $false} | export-SCOMmanagementpack -path C:\MPBackups

Now, I could be creative and go through all of the steps required to create an automated task with SCOM 2012 or SCORCH 2012 to run this on a daily basis, but instead, I'll point you in the direction of an excellent series on backing up your SCOM environment from start to finish that was written by a System Center buddy of mine called 'Dieter Wijckmans'.

Check out his posts from the link below and make sure to use the script modifications above if you are backing up your new System Center 2012 Operations Manager environment:

http://scug.be/blogs/dieter/archive/2011/06/22/scom-2007-how-to-backup-your-environment.aspx

Enjoy!

3 comments:

  1. The OpsMgr 2012 version of this pack is available at http://www.systemcentercentral.com/PackCatalog/PackCatalogDetails/tabid/145/indexid/95769/Default.aspx

    ReplyDelete
    Replies
    1. Thanks for the reminder Pete ;) - forgot to update the post since this new MP release. As usual, thanks a million to you and the guys for releasing these excellent MP's for free!

      Kevin

      Delete