Wednesday, June 28, 2017

Unsealed management pack backups

I have finally created an updated version of the old management pack backups script I created with a colleague in a previous life.

You can use this one to schedule your unsealed MP backups on a regular basis. Just update the location of the backup folder (highlighted), save as a .ps1 file and go.

Have tested on OpsMgr 2012 and OpsMgr 2016.

 

##############################################################################
#
#   SCOM-UnsealedMP-Backup.ps1
#
#    This script backs up all unsealed management packs to a folder with the backup date as folder name
#
##############################################################################

# Variables

$ReportDate = Get-Date -format "yyyy-M-dd"
$path = "c:\Backups\$ReportDate\"


# there should be no need to update the script beyond this point

# test if the folder exists, and, if not, create it

If (!(Test-Path $path)){
    New-Item -ItemType directory -Path $path
}

# Connect to Operations Manager

Import-module OperationsManager

# get all the unsealed management packs and create array

$MPS = Get-SCOMManagementPack | where {$_.Sealed -eq $false}

# step through the management packs and export them to the folder specified
foreach($mp in $mps)
{
export-SCOMmanagementpack -managementpack $mp -path $path
}

No comments:

Related Posts with Thumbnails