Here's a cool tip from Ritesh Grover, one of Microsoft's excellent support engineers on the 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)