OpsMgr 2007: How to get the list of all the computers in Maintenance Mode

Here's a cool tip from Ritesh Grover, one of our top support engineers on our Operations Manager team.  If you're looking for a script to quickly get a list of the computers that are in Maintenance Mode then this should do the trick:


To get a list of all computers and components that are in Maintenance Mode, copy and paste the below script in .ps1 format and run the script from an OpsMgr 2007 PowerShell console.  If a specific component is not in Maintenance Mode then it will give you an error for that component:

***************************Script Starts****************************
$Group='All Computers'

$groupObject = get-monitoringobject | where {$_.DisplayName -eq $group};
$groupagents = $groupObject.getrelatedmonitoringobjects()

foreach ($agent in $groupAgents)


$computerPrincipalName = $agent.displayname

$computerClass = get-monitoringclass -name:Microsoft.Windows.Computer
$healthServiceClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthService
$healthServiceWatcherClass = get-monitoringclass -name:Microsoft.SystemCenter.HealthServiceWatcher

$computerCriteria = "PrincipalName='" + $computerPrincipalName + "'"

$computer = get-monitoringobject -monitoringclass:$computerClass -criteria:$computerCriteria

$healthServices = $computer.GetRelatedMonitoringObjects($healthServiceClass)

$healthService = $healthServices[0]

$healthServiceCriteria = "HealthServiceName='" + $computerPrincipalName + "'"

$healthServiceWatcher = get-monitoringobject -monitoringclass:$healthServiceWatcherClass -criteria:$healthServiceCriteria
Write-host "****************************"
Write-host "****************************"
Write-host " "

Write-host "Computer"
Write-host " "
Get-MaintenanceWindow -monitoringobject:$Computer

Write-host "Health Service"
Write-host " "
Get-MaintenanceWindow -monitoringobject:$HealthService

Write-host "HealthServiceWatcher"
Write-host " "
Get-MaintenanceWindow -monitoringobject:$healthservicewatcher


***********************************END Script**************************************

Sample Output:



Get-MaintenanceWindow : The MonitoringObject is not in maintenance mode.
At C:\mw.ps1:37 char:22
+ Get-MaintenanceWindow  <<<< -monitoringobject:$Computer

Health Service

Get-MaintenanceWindow : The MonitoringObject is not in maintenance mode.
At C:\mw.ps1:41 char:22
+ Get-MaintenanceWindow  <<<< -monitoringobject:$HealthService


MonitoringObjectId : 81c07224-ea63-3206-937f-77d1efc29c86
StartTime          : 10/14/2008 11:40:40 PM
ScheduledEndTime   : 10/15/2008 12:10:40 AM
EndTime            :
Reason             : UnplannedOther
Comments           :
User               : DOMAINSMS\OpsAdmin
LastModified       : 10/14/2008 11:40:40 PM
ManagementGroup    : MGLab
ManagementGroupId  : 3c3c8575-97dc-4e54-b4cc-1fffecffb7bf

So for the computer ComputerName in the above example output, Computer and Health Service error out but  HealthServiceWatcher gave valid data as only HealthServiceWatcher was in Maintenance Mode.

Note that the script above will check all the computers.  If you want to check for specific computers replace the $Group variable value with the group you wish to check.


Thanks Ritesh!

J.C. Hornbeck | Manageability Knowledge Engineer

Comments (3)

  1. Anonymous says:

    How to extract the list of objects present with a custom group?


  2. show box says:

    Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
    For more info on showbox please refer below sites:
    Latest version of Showbox App download for all android smart phones and tablets.
    http://movieboxappdownloads.com/ – It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
    For showbox on iOS (iPhone/iPad), please read below articles:
    Showbox for PC articles:
    There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment
    it doesn’t charge cash for watching films and recordings.
    http://www.showboxforipad.org/showbox-apk/ Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android. The above
    all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on ‘Obscure sources’.
    Movie Box, an esteemed movies application in which you can find stacks of programs and films. The guide is given here to download Movie Box app to Android and to Apple iOS 9.0.2, iOS 8.4/8.3 and also for the lower versions without Jailbreak.
    Please do login to Showbox application with the help of Ymail. You can login in Ymail from here –
    Sign Up & Do registration for latest movies on Showbox application

Skip to main content