SCOM Maintenance Mode PowerShell

My thanks to Matt Taylor and Kevin Holman for their guidance!


Read on if these apply
Trying to start, update, or end SCOM MM

Get alerts when MM is updated
PowerShell only in your shop!
SCORCH in play but need to convert runbooks to straight PowerShell

Ran into issues using Set-SCOMMaintenanceMode, as the cmdlet doesn't put ALL the recursive classes under Windows Computer




Set-SCOMMaintenanceMode cmdlet is actually “by design.”  ☹


Start-SCOMMaintenanceMode assumes you want recursive action when you start maintenance mode…. So you pick a Windows Computer and it places the Windows Computer object (AND all contained objects) into MM.

Computer in MM

All contained objects in MM



However, the problem is that Set-SCOMMaintenancemode does not have an understanding of recursiveness.  It changes the MM entry for the Windows Computer, but NOT all the contained objects.  So they retain the original setting.


Health explorer looks like this, resulting in unwanted alerts





NOTE these $Time and DateTime Method are dependent on the delay between running the commands
If you start MM, and wait 5 minutes, then update, the total MM duration will be ~20 minutes


# Start MM

$server = "Servername.FQDN"

$instance = (get-scomclass -DisplayName "Windows Computer" |Get-SCOMClassInstance | ? { $_.DisplayName -eq $server } )
$Time = (Get-Date).addMinutes(6)
Start-SCOMMaintenanceMode -Instance $Instance -EndTime $Time -Comment "Starting Maintenance Mode." -Reason "PlannedOther"


# Update MM
# Make sure you've put object in MM
$guid = $
$WCobj = Get-SCOMMonitoringObject -Id $guid

# 15 minutes in the future
$WCobj.UpdateMaintenanceMode([System.datetime]::Now.addminutes(15).touniversaltime(),[Microsoft.EnterpriseManagement.Monitoring.MaintenanceModeReason]::PlannedOther,[System.string]::"Adding 15 minutes to the end time.",[Microsoft.EnterpriseManagement.Common.TraversalDepth]::Recursive);


# Stop MM
# Make sure you've put object in MM

# Immediate

# 15 minutes in the future

# 1 hour in the future


# Validate MM through Operations Manager Event ID’s 1215 and 1216 logged

get-eventlog -LogName "Operations Manager" | ? { $_.EventID -eq 1215 -OR $_.EventID -eq 1216 } |fl EventID,TimeGenerated,Message



# Error if object NOT in MM

Cannot find an overload for "UpdateMaintenanceMode" and the argument count: "1".

At line:1 char:1

+ $WCobj.UpdateMaintenanceMode(([System.datetime]::Now).addminutes(15). ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodException

    + FullyQualifiedErrorId : MethodCountCouldNotFindBest


PS C:\Windows\system32>


Testing System datetime

PS C:\Windows\system32> [System.datetime]::Now.addminutes(15)


Thursday, August 24, 2017 9:18:04 AM



PS C:\Windows\system32> ([System.datetime]::Now.addminutes(15)).touniversaltime()


Thursday, August 24, 2017 2:18:16 PM







DateTime Methods

MaintenanceModeReason Method

StopMaintenanceMode Method

UpdateMaintenanceMode Method


MM deluxe custom script

Comments (0)

Skip to main content