With Operations Manager 2007 and 2007 R2, scheduling maintenance mode for a group of servers during a defined service window typically required using a custom PowerShell script, management pack, or custom program (just to name a few solutions/approaches readily available). With System Center Orchestrator and the Operations Manager 2012 Integration Pack, you have learned how we can leverage a single solution to automate maintenance mode for a single agent-managed system, or multiple systems depending on your requirements.
This solution is using a SQL query against the Operations Manager operational (OperationsManager) database. I decided to take this approach for two reasons – efficiency and simplicity. Sure I could have done this in PowerShell, but until recently I found there were challenges with running PowerShell scripts that invoke cmdlets from any one of the Microsoft products that leverage PowerShell for administration (there are multiple blog posts on this topic providing different guidance on how to approach this if you search on PowerShell and Orchestrator). Next posting I’ll share how this can be accomplished with PowerShell using a few lines of code.
The following example demonstrates how to start maintenance mode for all members of a group.
1. On the computer where the Runbook Designer is installed, click Start, point to All Programs, click System Center 2012 – Orchestrator, and then click Runbook Designer.
2. In Runbook Designer, in the Connections pane, click the Runbooks folder.
3. In the Connections pane, click the Create a new runbook icon
4. In the Runbook Designer Design workspace, right-click the Runbook tab, and then select Rename.
5. Enter a name for the runbook, such as “SchedMMode” and press Enter.
6. Create a Schedule (under Global Settings) and call it “Svc Window – Saturday 9PM-1AM” and set it so that it runs on any Saturday, and that the only hour permitted is from 9 pm to 1 am.
7. From the Connections pane in the Runbook Designer, expand the Global Settings folder, and click the Variables folder.
8. Right-click the Variables folder or a subfolder of the Variables folder, point to New, and then click Variable to open the New Variable dialog box.
9. Type a Name for the variable. This variable will represent the actual name of the group defined in Operations Manager that we will be querying for the members of the group to place into maintenance mode.
10. Type a Description that explains the purpose of the variable.
11. Type the Value of the variable, which is the actual name of the group in Operations Manager. This value replaces the placeholder in the Query Database activities where the variable is inserted.
12. Click Finish.
13. In the Activities pane, drag the Monitor Date/Time activity from the Scheduling category to the Design workspace of your runbook.
14. Double-click the Monitor Date/Time activity to open the Properties dialog box for that activity.
15. In the properties for the Monitor Date/Time activity, on the Details tab for the At setting, select an absolute time for the runbook to run that aligns with the start time of your scheduled service window. For example, if it is scheduled for 9:00 PM, select 9:00 PM for the value.
16. Click Finish.
17. In the Activities pane, drag the Check Schedule activity from the Scheduling category to the Design workspace of your runbook.
18. Double-click the Check Schedule activity to open the Properties dialog box for that activity.
19. Select the Details tab, and next to the Schedule Template box, click the ellipsis (…) button and in the Select a Schedule dialog box, select the Schedule that you created in step 6.
20. Click Finish.
21. In the Activities pane, drag the Query Database activity from the Utilities category to the Design workspace of your runbook.
22. Double-click the Query Database activity to open the Properties dialog box for that activity.
23. Select the Details tab, and in the Query text box, copy and paste the following query:
select TargetObjectDisplayName as ‘Group Members’
AND SourceObjectDisplayName = ‘<reference the variable created in step 7-12> ‘
ORDER BY TargetObjectDisplayName
24. Select the Connection tab, and select from the Database type drop-down list, SQL Server. For Authentication, verify the radio button for Windows Authentication is selected.
25. On the Connection tab, and next to the Server box, type in the fully qualified domain name (FQDN) for the SQL Server hosting the Operations Manager operational database.
26. On the Connection tab, and next to the Initial Catalog box, type in the name of the Operations Manager operational database, which by default is OperationsManager.
27. On the Security tab, provide a username and password of an account that has read rights to the OperationsManger database. By default, the service account associated with the Runbook service has not been granted this right to the database and this activity will fail by default.
28. Click Finish.
29. In the Activities pane, drag the Start Maintenance Mode activity from the SC 2012 Operations Manager category to the Design workspace of your runbook.
30. Create smart links between the Monitor Date/Time, Check Schedule, Query Database, and Start Maintenance Mode activities.
31. Double-click the Start Maintenance Mode activity to open the Properties dialog box for that activity.
32. Select the Details tab, and next to the Server Connection box, click the ellipsis (…) button and in the Item Selection dialog box, select the connection defined for the Operations Manager Integration Pack.
33. Next to the Monitor box, type the following: Microsoft.Windows.Computer: and then right-click and select Subscribe\Published Data.
34. In the Published Data dialog box, verify in the Activity drop-down list the Query Database activity is selected and in the middle pane select the published data – Full line as a string… and press the OK button.
35. Next to the Reason box, click the ellipsis (…) button and in the Reasons dialog box, select the appropriate reason from the list and press OK.
36. Next to the Duration box, enter a value representing the total number of minutes to place the monitored objects returned from the Query Database into maintenance mode.
37. Next to the Comment box, type in a comment to indicate why the maintenance mode activity is initiated for the monitored object.
38. Click Finish.
The other activities in the runbook are utilizing the Operations Manager Create Alert activity to handle errors that may arise and inform when the runbook completes successfully.
I can confirm from testing that the Start Maintenance Mode activity does place the object and all child objects into maintenance mode. Hopefully you experience the same results as I do.
Any questions, feel free to email me at firstname.lastname@example.org.