Sometimes you stumble upon on a request to put a group of computers in Maintenance Mode. You can create an explicit group by hand, and then schedule a maintenance mode (or use PowerShell) or…you can create a dynamic group of computers that host an specific type of instance and put that in maintenance. This saves you manual labor and it is always 100% correct and automated.
Create a Maintenance Mode entry using PowerShell
Defining variables
$ManagementServer = "scom.domain.nl"
$GroupName = "Application Servers"
$Minutes = "120"
$Reason = "PlannedOther"
$Comment = "Nodes in maintenance"
Starting Maintenance Mode for all objects in a group
Import-Module OperationsManager
New-SCOMManagementGroupConnection -ComputerName $ManagementServer
$SCOMGroup = Get-SCOMGroup | where {$_.DisplayName -like "$GroupName"}
$Time = ((Get-Date)).AddMinutes(($Minutes))
Start-SCOMMaintenanceMode -Instance $SCOMGroup -EndTime $Time -Reason "$Reason" -Comment $Comment
Optional: Update an existing Maintenance Mode entry
Import-Module OperationsManager
New-SCOMManagementGroupConnection -ComputerName $ManagementServer
$SCOMGroup = Get-SCOMGroup | where {$_.DisplayName -like "$GroupName"}
$MMEntry = Get-SCOMMaintenanceMode -Instance $SCOMGroup
$NewEndTime = (Get-Date).addDays(2)
Set-SCOMMaintenanceMode -MaintenanceModeEntry $MMEntry -EndTime $NewEndTime -Comment "Adding two days"
Maintenance Mode Reasons
The cmdlets Start-SCOMMaintenanceMode
and Set-SCOMMaintenanceMode
accept the following reasons
PlannedOther
UnplannedOther
PlannedHardwareMaintenance
UnplannedHardwareMaintenance
PlannedHardwareInstallation
UnplannedHardwareInstallation
PlannedOperatingSystemReconfiguration
UnplannedOperatingSystemReconfiguration
PlannedApplicationMaintenance
UnplannedApplicationMaintenance
ApplicationInstallation
ApplicationUnresponsive
ApplicationUnstable
SecurityIssue
LossOfNetworkConnectivity
Visual Studio Authoring Extensions Snippet
A snippet for VSAE that can be used to create groups with computers that host instances of a specific class can be found here: