What SCOM Objects are in Maintenance Mode (SQL Query)

If you want to find out what objects are currently in Maintenance Mode, here’s a nice bit of SQL Code you can use for just that. I’ve added a more useful English Reason than just the code because SCOM stores the code itself in the Database. It’s a lot easier in my opinion to identify the reason as server was put into maintenance that just code 8 or 9.

Here it is, enjoy.

Use [OperationsManager]

FullName as [Object in Maintenance],
TimeAdded as [Time Added],
StartTime as [Start Time],
ScheduledEndTime as [Scheduled End Time],
dbo.MaintenanceMode.[User] as [User],
Case ReasonCode
When 0 then ‘Other (Planned)’
When 1 then ‘Other (Unplanned)’
When 2 then ‘Hardware: Maintenance (Planned)’
When 3 then ‘Hardware: Maintenance (Unplanned)’
When 4 then ‘Hardware: Installation (Planned)’
When 5 then ‘Hardware: Installation (Unplanned)’
When 6 then ‘Operating System: Reconfiguration (Planned)’
When 7 then ‘Operating System: Reconfiguration (Unplanned)’
When 8 then ‘Application: Maintenance (Planned)’
When 9 then ‘Application: Maintenance (Unplanned)’
When 10 then ‘Application: Installation (Planned)’
When 11 then ‘Application: Unresponsive’
When 12 then ‘Application: Unstable’
When 13 then ‘Security issue’
When 14 then ‘Loss of network connectivity (Unplanned)’
End as [Reason for Maintenance],
FROM BaseManagedEntity INNER JOIN
MaintenanceMode ON BaseManagedEntity.BaseManagedEntityId = MaintenanceMode.BaseManagedEntityId
WHERE IsInMaintenanceMode = 1

List of Reason Codes
0: Other (Planned)
1: Other (Unplanned)
2: Hardware: Maintenance (Planned)
3: Hardware: Maintenance (Unplanned)
4: Hardware: Installation (Planned)
5: Hardware: Installation (Unplanned)
6: Operating System: Reconfiguration (Planned)
7: Operating System: Reconfiguration (Unplanned)
8: Application: Maintenance (Planned)
9: Application: Maintenance (Unplanned)
10: Application: Installation (Planned)
11: Application: Unresponsive
12: Application: Unstable
13: Security issue
14: Loss of network connectivity (Unplanned)

The result will be something like this…


Leave a Reply

Your email address will not be published.