Maintenance Mode with PowerShell in SCOM 2012

With the upcoming version of Operations Manager 2012 there has been som changes in the PowerShell commands. For example the command for putting objects in Maintenance Mode.

The command in SCOM 2007 is New-MaintenanceWindow and for SCOM 2012 it has changed to Start-SCOMMaintenanceMode.

Example of putting an IIS 7 Application Pool in MM in SCOM 2007 R2:

$objMonClass = get-monitoringclass | where-object {$_.Name -eq "Microsoft.Windows.InternetInformationServices.2008.ApplicationPool"}
$objPool1 = get-monitoringobject -MonitoringClass $objMonClass | where-object $_.DisplayName -match "AppPoolName"}
$time = [DateTime]::Now
New-MaintenanceWindow -starttime: ($time) -endTime: $time.AddHours(0.2) -monitoringobject:$objPool1 -reason: "PlannedOther" -comment: "Test of MM for AppPool"

Example of putting the same Application Pool in MM in SCOM 2012:

$objMonClass = get-SCOMclass | where-object {$_.Name -eq
$objPool1 = get-scomclassinstance -Class $objMonClass | where-object {($_.Path -match "") -and ($_.DisplayName -match "AppPoolName")}
$time = [DateTime]::Now
Start-SCOMMaintenanceMode -instance $objPool1 -endtime $time.addHours(0.2) -reason "PlannedOther" -comment "Test of MM for AppPool"

SCOM 2007 R2, SCOM 2012

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.