So what is in maintenance mode?

In MOM 2005 you could put computers into maintenance mode; in OpsMgr 2007 maintenance mode is much more granular. Instead of putting the whole computer into maintenance mode, you can put a particular database or NT service into maintenance mode. At times it can be challenging to figure out what do you actually have in maintenance mode, when did the maintenance mode start and when will it finish, and finally why a particular component is in maintenance mode. Here is a script that I put together that should simplify understanding what is actually in maintenance mode.

$criteria = new-object Microsoft.EnterpriseManagement.Monitoring.MonitoringObjectGenericCriteria("InMaintenanceMode=1")

$objectsInMM = (Get-ManagementGroupConnection).ManagementGroup.GetPartialMonitoringObjects($criteria)

$objectsInMM | select-object DisplayName, @{name="Object Type";expression={foreach-object {$_.GetLeastDerivedNonAbstractMonitoringClass().DisplayName}}},@{name="Start Time";expression={foreach-object {$_.GetMaintenanceWindow().StartTime.ToLocalTime()}}},@{name="End Time";expression={foreach-object {$_.GetMaintenanceWindow().ScheduledEndTime.ToLocalTime()}}},@{name="Path";expression={foreach-object {$_.Path}}},@{name="User";expression={foreach-object {$_.GetMaintenanceWindow().User}}},@{name="Reason";expression={foreach-object {$_.GetMaintenanceWindow().Reason}}},@{name="Comment";expression={foreach-object {$_.GetMaintenanceWindow().Comment}}}

Basically this script does the following:

1 - Creates a criteria object to specify that we want only the objects that are in maintenance mode

2 - Issues a query to the SDK service with the specified criteria

3 - The rest is formatting the data into a table

Script Output

ScriptOutput.jpg