Operations Manager

Schedule maintenance mode for group (easy)

One of the most annoying things whit System Center Operations Manager is the lack of maintenance mode scheduling built in. (You have some options, with Orchestrator, SCCM etc). One thing I personally struggle with, is to maintenance mode every server during Windows Update since we use WSUS for patching and not SCCM. but that’s not the purpose of this post.

In this post, i will guide you through how you can schedule maintenance mode for a (SCOM) group of computers with tools you already have installed – Powershell and Task Scheduler. In our environment we have some Citrix XenApp servers which are scheduled to reboot every night. Since they boot at the exact same time they are easier to maintenance mode than all other servers that boot randomly during updates.

This post will guide you through the following.

  • Create a dynamic group containing the servers (I will use OU in this example, but you are free to use what ever you like)
  • The Powershell script to run against OpsMgr
  • Configuration of the Scheduled task.

Creating the dynamic group

Under Authoring in your console, create a new group. I have called mine “Citrix Servers” stored in a custom management pack. Under dynamic members you will have to create a formula to populate the group members. Her you can choose the solution that fit your needs, but I will be using OU, as our Citrix servers are stored in their own OU.

Dynamic group based on OU
Dynamic group based on OU

( Object is Windows Computer AND ( Organizational Unit Matches wildcard *OU=Citrix* ) AND True )

If you have some servers in the same OU, that you do not want included in this group. You can add them in the “exculded members” pane. Once your group is created, allow for the “System Center Minute” to complete, and if everything is OK, you should see your servers.

TIP: Finding a coumputers OU. Check its Properties under Windows Computers


The Powershell script and task

Since were not allowed to start maintenance mode ahead in time, we have to rely on our favorite automation tool called Powershell. In the OpsMgr module there is a Cmdlet, Start-ScomMaintenanceMode, which have a time variable.

Start-MaintenanceMode on technet

param($ManagementServer, $GroupName, $Minutes, $Reason, $Comment)

Import-Module OperationsManager #Import the opsmgr module
New-SCOMManagementGroupConnection -ComputerName $ManagementServer #connect to MS
$SCOMGroup = Get-SCOMGroup | where {$_.DisplayName -like "$GroupName"} #Get the scom group to maintenance
$Time = ((Get-Date)).AddMinutes(($Minutes)) #get time and date. Add minutes. This will be how many minutes object is in maintenance mode
Start-SCOMMaintenanceMode -Instance $SCOMGroup -EndTime $Time -Reason "$Reason" -Comment $Comment
-Command "z:\path\script.ps1 - ManagementServer 'ManagementServerFQDN' -GroupName 'GroupDisplayName' -Minutes 'XX' -Reason 'YourReason' -Comment 'YourCommentHere' ; exit $LASTEXITCODE"

Creating the task

Start by creating a new Scheduled task. Under triggers, set the time and all other configuration you will need.

Under ‘actions’ browse to system32 and add powershell as the program to run. (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe) Under arguments, edit to fit your needs and paste in the above.

Reasons accepted

— PlannedOther
— UnplannedOther
— PlannedHardwareMaintenance
— UnplannedHardwareMaintenance
— PlannedHardwareInstallation
— UnplannedHardwareInstallation
— PlannedOperatingSystemReconfiguration
— UnplannedOperatingSystemReconfiguration
— PlannedApplicationMaintenance
— ApplicationInstallation
— ApplicationUnresponsive
— ApplicationUnstable
— SecurityIssue
— LossOfNetworkConnectivity

Verify that everything works as expected

Event Viewer


Operations Console



Hope this get you on your way to schedule maintenance mode. When I decide to use SCCM to do our patching, or we come up with another idea, I will let you know.

As always – complete this in your test environment to confirm it’s working.
PS: Operations Manager 2016 will have scheduling built in.

Engage by commenting