Call us Today! (650) 453-8152

Scripting Maintenance Mode in SCOM 2012

Scripting Maintenance Mode in SCOM 2012

Posted by aeadmin on Feb 16, 2016 9:04:16 AM


Hello fellow SCOM’ers. Today, we wanted to share with you all an easy way to script maintenance mode in SCOM 2012. If you don’t want to manually run this, you can run it as a scheduled task. We like to manage this manually by running the script ourselves, but to each their own. Happy scripting!


GroupMaintMode -ScomServer “<scomserver>” -GroupDisplayName “<groupname>” `
-DurationInMin 10  -Reason “<reasonformaint” -Comment “<comment>”


#--------Begin Sample Script----------------


# Name: SCOM 2012 Maint Mode PS Script


#  Parameters:


# -ScomServer: contians SCOM server name

# -GroupDisplayName: contains display name of the target group

# -DurationInMin: contains integer of desired duration in minutes

# -Reason: values are UnplannedOther, PlannedHardwareInstallation,

#           PlannedHardwareMaintenance, UnplannedHardwareMaintenance,

#           UnplannedHardwareInstallation, PlannedOperatingSystemReconfiguration,

#           UnplannedOperatingSystemReconfiguration, PlannedApplicationMaintenance,

#           ApplicationInstallation, ApplicationUnresponsive, ApplicationUnstable,

#           SecurityIssue, LossOfNetworkConnectivity

# -Comment: optional parameter



Function GroupMaintMode

#($ScomServer, $GroupDisplayName, $DurationInMin, $Reason, $Comment)









Import-Module OperationsManager

New-SCOMManagementGroupConnection -ComputerName $ScomServer


ForEach ($Group in (Get-ScomGroup -DisplayName  $GroupDisplayName))


If ($group.InMaintenanceMode -eq $false)


$group.ScheduleMaintenanceMode([datetime]::Now.touniversaltime(), `

([datetime]::Now).addminutes($DurationInMin).touniversaltime(), `


"$Reason", "$Comment" , "Recursive")





Written and composed by one of our Senior Microsoft System Center Architects, Jessica Ervin-Hang

Tags: scom, PowerShell, system center