In my last post I published a GUI based tool to put Windows and UNIX/Linux computer into maintenance mode. After great success, there were requests to have some sort of scheduling mechanism for setting maintenance mode on a regular time schedule. Well, as I have mentioned in my previous post, there are many ways to achieve this goal. In some cases the easiest way would be to use Scheduled Tasks and schedule a console application. This is exactly what I am going to provide you with this post.
Based on the same code as the previous GUI tool I just had to change the GUI itself and use the functions in a console application. Of course, I added some more bells and whistles and finally I think it will satisfy most of the needs.
The console application looks like this…
How does it work?
The tool is called MMCTool.exe…
…which stands for Maintenance Mode Console Tool, yeah I know, not very exciting name 🙂 . Download the ZIP file which contains 3 SCOM 2012 SP1 UR4 SDK dll’s and the MMCTool.exe and extract it into a folder e.g. c:\MMCTool…
Just open a command prompt and run C:\MMCTool\MMCTool.exe and you will see all the parameters which the tool needs to run.
I think it is pretty easy to understand what it is all about, if you are used to set maintenance mode in SCOM.
A sample command to start maintenance mode for computer dc01.bigfirm.com for 60 minutes on SCOM management server om2012.bigfirm.com would look like this…
MMCTool -ms=om2012.bigfirm.com -s=dc01.bigfirm.com -min=60 -c=”Windows Computer” -d=”Setting maintenance mode for patch installation” -action=start -cat=PlannedApplicationMaintenance
If you would like to stop maintenance mode you can use the same command as above and just change the –action argument to “stop” or use the minimal required parameter like this…
MMCTool -ms=om2012.bigfirm.com -s=dc01.bigfirm.com -c=”Windows Computer” -action=stop
And if you would like to get information about maintenance mode change the –action argument to “get”…
MMCTool -ms=om2012.bigfirm.com -s=dc01.bigfirm.com -c=”Windows Computer” -action=get
As you can see everything works as you would expect.
Scheduling MMCTool
If you would like to schedule maintenance mode you could use Scheduled Tasks. In my case I am going to use Windows 7 to run the task. Go to Scheduled Tasks and select Create Basic Task…
Choose how often to run…
In my case I want to run it every day at 18:00…
Choose Start a program…
Paste your command you would like to execute. I used the command…
C:\MMCTool\MMCTool -ms=om2012.bigfirm.com -s=dc01.bigfirm.com -min=60 -c=”Windows Computer” -d=”Setting maintenance mode for patch installation” -action=start -cat=PlannedApplicationMaintenance
The wizard will detect that we run the exe with some parameters, click Yes…
Check that everything is ok and select Open the Properties dialog for this task when I click Finish…
I created a service account under which this task runs and therefore also the MMCTool. Important: Make sure this account has on the system which runs the task at least Logon as a batch job permission and also permission in SCOM to run maintenance mode. I added the svc_task user into the local administrator group of the Windows 7 machine and gave Operations Manager Operator permission on the management server.
When you click ok you have to type the password…
Finally, we have a scheduled task to execute maintenance mode…
Again, I have tested it on several systems BUT there might be a certain setup which could cause a problem. If so, let me know.
Run this tool on your own risk! I am not responsible for any damage or any other problems this tool causes! Try it out in your lab first!
Can you use groups to do scheduled maintenance with this tool?
Hi
It is not inteded to use with groups.
Cheers,
Stefan
Do you know of a way to use this or your GUI version to put servers into MM from a gateway’ed environment (untrusted forest)?
Hey Stefan,
I don’t think the code likes dashes in the server names. All of my lab servers have dashes in their names and I cannot get this code to work for the life of me. Can you try it out and let me know?
Hi,
Ok, I will check and fix.
Cheers,
Stefan