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

Comments (6)

  1. Anonymous says:

    There are many articles that talk about maintenance mode in System Center Operations Manager 2007. Topics

  2. Anonymous says:

    small correction for script above.

    To get the Comment to show, change this:

    $_.GetMaintenanceWindow().Comment

    to this:

    $_.GetMaintenanceWindow().Comments

  3. Anonymous says:

    Check out Boris Yanushpolsky's blog ( http://blogs.msdn.com/boris_yanushpolsky ). Boris is an SCOM

  4. Anonymous says:

    Great post. Is it possible to schedule this (and export to html)? I can’t get it to work, just running the ps1 doesn’t work, though the execution policy is set correctly.