See if you can find this script useful, just place servers line by line in ServerList.txt and run this PS from same location where you have placed this file, specify parameters as mentioned below.....
param([int32]$TimeMin, [string]$Reason, [string]$Comment)
Try
{
$api = new-object -comObject 'MOM.ScriptAPI'
Import-Module operationsmanager
New-SCOMManagementGroupConnection
$Servers = Get-Content "ServerList.txt"
$Time = (Get-Date).Addminutes($TimeMin)
Foreach ($Server in $Servers)
{
#Get Computer instance
$ComputerClass = Get-SCOMClass -Name Microsoft.Windows.Computer
$ComputerClassInstance = Get-SCOMClassInstance -Class $ComputerClass | Where {$_.DisplayName -eq $Server}
If ($ComputerClassInstance -ne $Null)
{
$HealthServiceWatcherClass = Get-SCOMClass -name:Microsoft.SystemCenter.HealthServiceWatcher
#Get Health Service Watcher Class instance of the server
$HSWClass = Get-SCOMClass -Name Microsoft.SystemCenter.HealthServiceWatcher
$HSWClassIns = Get-SCOMClassInstance -Class $HSWClass | Where {$_.DisplayName -eq $Server}
#Starting the maintenance mode
Start-SCOMMaintenanceMode -Instance $HSWClassIns -EndTime $Time -Reason $Reason -Comment $Comment
Start-SCOMMaintenanceMode -Instance $ComputerClassInstance -EndTime $Time -Reason $Reason -Comment $Comment
Write-Host "Health Service Watcher and Agent server "$Server " kept in maintenance mode" -foregroundcolor "green"
#Logging success event
$api.LogScriptEvent('MaintenanceModeScript.ps1', 200, 0, "$Server kept in maintenance mode for $TimeMin minutes")
}
Else
{
Write-Host $Server" not found in your domain " -foregroundcolor "red"
#Logging error event
$api.LogScriptEvent('MaintenanceModeScript.ps1', 101, 1, "$Server could not be found in your domain")
}
}
}
Catch [system.exception]
{
$api.LogScriptEvent('MaintenanceModeScript.ps1', 101, 1, $_.Exception.Message)
}