Thursday, September 28, 2017

SCSM Unsealed MP backups

I have now also created an updated version of the unsealed MP backup script that works with System Center Service Manager.

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 SCSM 2012 and SCSM 2016

##############################################################################
#
#   SCSM-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 Service Manager

# Service Manager Administrator Module
$InstallationConfigKey = 'HKLM:\SOFTWARE\Microsoft\System Center\2010\Service Manager\Setup'
$AdminModule = (Get-ItemProperty -Path $InstallationConfigKey -Name InstallDirectory).InstallDirectory + "Powershell\System.Center.Service.Manager.psd1"
Import-Module -Name $AdminModule

#Connect to management server
$ServerConfigKey = 'HKCU:\Software\Microsoft\System Center\2010\Service Manager\Console\User Settings'
$SvcMgmtSrv = (Get-ItemProperty -Path $ServerConfigKey).SDKServiceMachine
New-SCManagementGroupConnection -ComputerName $SvcMgmtSrv


# get all the unsealed management packs and create array

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

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



And thanks goes to Matthew Dowst for simplifying the SCSM module loading.

No comments:

Related Posts with Thumbnails