The fun starts here.
VMM is like more 3rd party management packs that require an app update, then push updates to SCOM.
The initial VMM MS configuration will upload the VMM UR packs to SCOM, but what do you do the next time you update VMM how do you upgrade SCOM to the latest UR?
Here’s a script to upgrade SCOM once VMM UR is updated on your VMM management server.
$UR=”UR11″
$VMMServer = “12VMM01”
# Set up your path, this example is monadmin\backup
$date = Get-Date -UFormat “%Y-%m-%d”
# Set up backup path
$backupPath = “C:\monadmin\backup”
$backupDrive = “C:”
####################################################################
# Functions
# Verify OperationsManager SnapIn Installed
Function VerifyOpsMgrSnapIn
{
If ( get-pssnapin -r | ? { $_.Description -contains “Operations Manager” } )
{
Write-host -f green “Operations Manager SnapIn already loaded!”
}
Else
{
add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”;
Write-host -f green “Operations Manager SnapIn loaded”
}
}
function BackupMP
{
if ( test-path -pathtype Container $backuppath )
{
new-item -itemtype directory -path $backupPath
write-host -f green “Created $backupPath ”
}
else
{
write-host -f green “Backup Path already created $backupPath ”
}
# Get VMM management pack versions before
$before = ( get-scommanagementpack -name “*VirtualMachineManager*” )
# Set up Backup Path
$backupDrive
cd $backupPath
new-item -itemtype directory -path $backupPath\$date
cd $backupPath\$date
new-item -itemtype directory -path $backupPath\$date\SCVMM_MP$UR
cd $backupPath\$date\SCVMM_MP$UR
# Copy SCVMM MP’s to SCOM MS
#
copy-item “\\$VMMServer\d$\Program Files\Microsoft System Center 2012 R2\Virtual Machine Manager\ManagementPacks\*” -destination $backupPath\$date\SCVMM_MP$UR
# Backup existing MP’s on SCOM MS
#
# Backup SCOM Management packs to C drive
$backupDrive
cd $backupPath
new-item -itemtype directory -path c:\monadmin\backup\$date\SCVMM_MP$UR_OLD
cd $date
Get-SCOMManagementPack -Name *VirtualMachine* | Export-SCOMManagementPack -Path “$backupPath\$date”
Write-Host -f green “MP’s backed up to $backupDrive\$backupPath\$date\SCVMM_MP$UR_OLD”
# Verify copy
if ( test-path -pathtype leaf $backupPath\$date\SCVMM_MP$UR\*.mp )
{
Write-Host -f green “MP’s copied”
}
else
{
Write-Host -f yellow “Specify proper path for MP’s copy”
}
}
Function ImportMPIntoSCOM
{
# Import VMM MP’s into SCOM
# http://www.systemcentercentral.com/bulk-import-operations-manager-2012-management-packs/
$mpdir = “$backupPath\$date\SCVMM_MP$UR”
$mpfiles = (Get-item -path $backupPath\$date\SCVMM_MP$UR\*).Name
$mpcnt = $mpfiles.Count
Write-Host “Script is requesting to import $mpcnt management packs.”
If ($mpcnt -gt 0)
{
Write-Host “$Instcnt management packs were added to installation queue, installing now”
foreach ($ManagementPack in $mpfiles)
{
Set-Location $mpdir
Import-SCOMManagementPack -Fullname $ManagementPack -ErrorAction SilentlyContinue
Write-host -f green “Imported $ManagementPack into SCOM”
}
}
}
VerifyOpsMgrSnapIn
BackupMP
#UpdateRegistry
ImportMPIntoSCOM
# Verify SCOM Management packs loaded
Write-host -f Green “Before Management pack versions”
$before.Version
Write-host
$after = ( get-scommanagementpack -name “*VirtualMachineManager*” )
$after.version
Write-host -f yellow “Is After greater than Before?”
Write-host