28 July 2009

SCOM: backup management packs

A colleague of mine has created a script for backing up management packs in SCOM, as follows:

Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
New-PSDrive -Name: Monitoring -PSProvider: OperationsManagerMonitoring
-Root: \
cd Monitoring:\
New-ManagementGroupConnection [rms]
cd [rms]

$all_mps = get-managementpack
foreach($mp in $all_mps)
{
export-managementpack -managementpack $mp -path "[backup path]"
}

Replace the following (including the brackets):

[rms]with the name of your RMS server (2 locations in script)
[backup path]
with the path where the backups should be written to e.g. c:\backups\
In powershell, run the following command:

set-executionpolicy remotesigned
This command sets your run permissions on your powershell scripts so you can run any locally created powershell script. Downloaded powershell scripts still need to be signed.

Save the script as a .ps1 file.

You can now schedule it through task scheduler as follows:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe powershell "full path to your powershell script, including the script name"

E.g.

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe powershell
"C:\Backups\Scripts\BackupSCOMMPs.ps1"
The script will export all management packs, sealed and unsealed, creating an XML file for each. Currently, the script will overwrite any existing files in the location specified

4 comments:

oliver said...

http://www.tek-tools.com/wordpress/

Daniele Muscetta said...

this obviously works... but why aren't you relying on something already more polished like the "Unsealed MP backup" solution that is here http://www.systemcentercentral.com/Downloads/DownloadsDetails/tabid/144/IndexID/7354/Default.aspx ?

Vanessa said...

@Daniele: the colleague who wrote the script created a couple of custom management packs and sealed them. He needed a way to back them up, and the Unsealed MP backup doesn't do it, because they are sealed.
The Unsealed MP backup is a great solution for unsealed MPs :)

Daniele Muscetta said...

when you use "export-managementpack", the sealed MPs are exported as XML anyway.

So what you need for those sealed MPs, is to keep a repository with your "source code", in all its versions, the needed references, and your signing key. And do a backup of THAT all.

if they are sealed, and you are referencing them, you will also need to re-seal them with THE SAME signing key...

Related Posts with Thumbnails