Backup your unsealed Management Packs

When Operations Manager has been running for a while, a couple of override MP’s are created that we don´t want to lose. Since there is no built-on function allows you to do this in Operations Manager, I wrote this script instead to make sure all my changes made are safely backed up on a regular basis.

So what does the script do?

The script looks after all unsealed Management Packs and then exports them to a file-path that´s specified in the script. Then the script can schedule by using Task Scheduler. It needs a folder to run in, e.g. E:\Backup.

How to use the script

The script is shown below and the only thing that needs to be changed before executing the script is the file-path, which is bold in the text below. Copy the script below and paste it into notepad before saving it as "Export.PS1"

param($ManagementServer)

Import-Module OperationsManager

New-SCOMManagementGroupConnection -ComputerName $ManagementServer

$Date = Get-Date -Format "yyyy-MM-dd"

$TodaysFolder = "E:\Backup\" + $Date

New-Item $TodaysFolder -ItemType directory -Force

$mp = Get-SCOMManagementPack | where {$_.Sealed -like "False"}

Export-SCOMManagementPack -ManagementPack $mp -Path $TodaysFolder

Set-Location -Path $TodaysFolder

Create a new task by using Windows Task Scheduler and follow these steps

  • Right click “Task Scheduler Library” and choose “Create Task”
  • In the General pane, Mark “Run whether user is logged on or not” and “Run with highest privileges”
  • You should also set the executing account to a service account, that way the script does not depend on a single persons account.
  • In the Trigger pane, set the schedule. See below for an example.

  • On the Actions pane, you need to tell the task what to do so click “New…” and then leave “Start a program” as it is.
  • In Program/Script, paste C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe which is the default path to Powershell.exe
  • In Arguments, paste the following line, edit the file-path to where you placed the script, and set your own Management Server name.
-Command "& E:\Backup\ManagementPacks\Export.ps1 -ServerName 'YourManagementServer' ; exit $LASTEXITCODE"

  • Click OK two times and enter the password for the service account to create the task.

Now when the task is created, you can test run the task by right clicking it and choose “Run”. Now, check the folder you created earlier and your unsealed management packs should now be exported to a folder matching today's date.

Wrap Up

This script is very easy to use and it makes the backup process completely automatic, something that at least makes me calm knowing that my changes in rules, monitors and overrides are safe.