Creating a SCOM 2016 Maintenance Schedule (and Conflicting Maintenance Schedules)

One of the hotly anticipated features of SCOM 2016 is the new Maintenance Mode updates, or more specifically…Maintenance Schedules as they are known…the ability schedule a maintenance in the future! Prior to SCOM 2016 we had to contend with doing it manually, or scripting up a solution and triggering that via a scheduled task.

In the SCOM Console the first thing you’ll notice in the Monitoring section is a new entry called “Maintenance Schedules”.

 

00-create-maintenance-schedule

 

 

 

 

 

 

 

 

Let’s create a new one. We’ll right click and choose “Create Maintenance Schedule” or from the actions menu choose “Create Maintenance Schedule” to start up a quick wizard.

 

0-create-maintenance-schedule

 

 

 

 

 

 

 

 

 

 

We’ll need to define the objects to put into maintenance.

wizard-1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So we’ll either choose “Selected objects only”…useful if we want to put only a specific object into maintenance such as a disk or a database. Or we’ll choose “Selected objects and all their contained objects” a more likely choice if you want to put a parent object like a server into maintenance and all of the child objects as well…Then we’ll click “Add/Remove Objects…” and locate our target object.

 

wizard-2-create-group-wizard

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In my case here I’ve selected a windows server. We’ll select that, click “Add” then “OK”.

Next we’ll need to define the schedule itself and this is a rather self explanatory screen. Simply choose when you want your schedule to work. Daily, weekly, monthly. Specific days of the week…what time to start and end the maintenance and what dates it should run from.

 

wizard-3-schedule

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Click “Next” and then give it a name, description and choose a reason for the maintenance. That’s it!

 

wizard-4-details

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When we click “Finish” the maintenance will be saved according to the schedule you chose and saved in the Operational Database.

And if you’re at all interested in scouting through the Operational Database you’ll find the schedules saved here:

 

maintenance-schedules-sql

 

 

 

 

So open up SQL Management Studio and run the following query:

Use [OperationsManager]
SELECT * FROM MaintenanceModeSchedule
ORDER BY [ScheduleName]

 

Of course you can also use Windows PowerShell to work with Maintenance Schedules. To find out what schedules you have type in:

Get-SCOMMaintenanceScheduleList

ScheduleId : ac2a298e-a963-e611-80b5-00155d019024
ScheduleName : Server Patching
IsEnabled : True
Status : NotRunning
IsRecurrence : False
ScheduledEndTime : 8/18/2016 8:57:17 PM
User : SCOM2016LAB\Administrator
LastRunStartTime : 8/18/2016 8:27:17 PM
NextScheduledRunTime : 1/1/0001 12:00:00 AM
LastModified : 8/16/2016 12:04:17 PM
ManagementGroup : SCOM2016LAB
ManagementGroupId : 7c97ef46-0495-1a15-64df-fad30796ed3d

ScheduleId : 377739f0-a963-e611-80b5-00155d019024
ScheduleName : Patch Tuesday
IsEnabled : False
Status : NotRunning
IsRecurrence : True
ScheduledEndTime : 1/1/0001 12:00:00 AM
User : SCOM2016LAB\Administrator
LastRunStartTime : 1/1/0001 12:00:00 AM
NextScheduledRunTime : 1/1/0001 12:00:00 AM
LastModified : 8/16/2016 12:07:02 PM
ManagementGroup : SCOM2016LAB
ManagementGroupId : 7c97ef46-0495-1a15-64df-fad30796ed3d

 

You’ll note from the output we have a ScheduleId…this is useful because we can use it to find out more about a specific Maintenance Schedule. We can then use the following command with the our ScheduleId like this:

Get-SCOMMaintenanceSchedule -ScheduleId 377739f0-a963-e611-80b5-00155d019024

ScheduleId : 377739f0-a963-e611-80b5-00155d019024
ScheduleName : Patch Tuesday
Recursive : True
IsEnabled : False
IsRecurrence : True
Status : NotRunning
MonitoringObjects : {024bf505-3e23-e4bc-4c1f-cfe6d347d352}
ScheduledEndTime : 1/1/0001 12:00:00 AM
IsEndTimeSpecified : False
Duration : 45
ActiveEndDate : 12/31/9999 11:59:59 PM
ReasonCode : PlannedOther
Comments : Weekly Patching Tuesday at 11pm.
User : SCOM2016LAB\Administrator
LastModified : 8/16/2016 10:07:02 PM
ScheduleRecurrence : Microsoft.EnterpriseManagement.Monitoring.MaintenanceSchedule.WeeklyRecurrence
ActiveStartTime : 8/22/2016 11:00:51 PM
ManagementGroup : SCOM2016LAB
ManagementGroupId : 7c97ef46-0495-1a15-64df-fad30796ed3d

 

Finally if you want to work with some of the other commands we have for Maintenances with SCOM:

Get-command *maint* | select Name

Name
—-
Disable-SCOMMaintenanceSchedule
Edit-SCOMMaintenanceSchedule
Enable-SCOMMaintenanceSchedule
Get-SCOMMaintenanceMode
Get-SCOMMaintenanceSchedule
Get-SCOMMaintenanceScheduleList
New-SCOMMaintenanceSchedule
Remove-SCOMMaintenanceSchedule
Set-SCOMMaintenanceMode
Start-SCOMMaintenanceMode
Stop-SCOMMaintenanceSchedule
Update-SCOMMaintenanceSchedule

 

Enjoy arguably the best feature in SCOM 2016.

 

Dealing with Multiple Conflicting Maintenance Schedules

If you try to place a maintenance on an object when another one already exists for a longer duration, both of them will be kept in the console and in the database but the duration of the most recently applied maintenance will be extended…well sort of. Confusing? Let’s look at this example:

I created 2 Maintenance Schedules:

  • The first was for 10 minutes and set to start at 3:35pm.
  • The second was for 5 minutes and set to start at 3:37pm.

So it should be clear that the second maintenance will finish first, at 3:42pm and the first maintenance should continue until 3:45pm.

The math seems to be right, but the execution seems to happen differently. Let’s look at what happened.

 

I created 2 Scheduled Maintenance’s in the Console. Here they are ready to run at 3:35 for 10 mins and 3:37 for 5 mins.

overlapping-maintenances-not-yet-running

 

 

 

 

 

Let’s wait until 3:35 pm when the first 10 minute maintenance should begin.

10-min-maintenance-running

 

 

 

 

 

If we use the Get-SCOMMaintenanceMode cmdlet we can clearly see the 10 Min maintenance is listed in the comments as the only thing we currently have causing objects to be in maintenance.

 

get-maintenancemode-10-minutes-id

 

 

 

 

 

 

 

Shortly after at 3:37 pm the 5 minute maintenance is scheduled to begin and it starts as expected. Notice both are running.

5-min-maintenance-running

 

 

 

 

If we switch to the Windows Computer view and have a look at our object we placed into maintenance…it shows the maintenance window as 5 minutes only…Wait? What?

Shouldn’t we have 8 minutes of Maintenance left from our original 10 minute maintenance?

overlapping-maintenances-windows-computer-object

 

 

 

 

 

 

But what about Windows PowerShell?

get-maintenancemode-5-minutes-id

 

 

 

 

 

 

It appears our 10 Minute Maintenance has been replaced with our 5 minute one! Wow does that mean we’ve trashed our original? Does that mean the original maintenance will end early now and potentially result in alerts we didn’t want?

No not exactly…check out the timestamps in the database. Our 10 minute maintenance is still there and enabled. It’s still going to hold those objects in maintenance but the gotcha is from our traditional Windows Computer views and the MaintenanceMode (old) cmdlets they are only going to show the latest applied maintenance.

overlapping-maintenances-scheduledendtime-updated

 

 

 

 

 

 

So a little something to be aware of when you create these overlapping schedules…but overall this is a great new feature of SCOM 2016 and you guys will get a lot of enjoyment out of this one.

 
Comments

I’ve noticed, that it when using a not default database name – like “OperationsManager16” this new feature does not work. A deeper research showed that in SQL Server Agent – Jobs the SQL-Job Step was created with the default Database name : “EXEC OperationsManager.dbo.p_MaintenanceScheduleJobStep …….” which resulted in a failed SQL Job execution and no MM applied.

Thanks for the comment Roman. I just ran into the same thing. I ended up modifying the jobs with the correct name as a work. Will update this post if I get a fix from Microsoft.

Leave a Reply