One more maintenance mode script

Attached is a script that takes a group and puts all the computers in the group (as well as the health service and the healthservice watcher) into maintenance mode.

Here is how you can run the script from the command line to start or stop maintenance mode (without launching powershell.exe)

One of the uses of this script is when you deploy hotfixes to a large number of servers. You can also very easily use Task Scheduler to run this script on a regular basis for your maintenance windows.

Starting MM – powershell “c:\GroupMM.ps1” -groupName:’All Computers’ -hours:10 -rmsServerName:’localhost’ -startMM:$true


Ending MM – powershell “c:\GroupMM.ps1” -groupName:’All Computers’ -hours:10 -rmsServerName:’localhost’ -startMM:$false

Comments (9)

  1. geist_23 says:


    I have used the maintenance mode scripts that target a group and that works great.  I have created a scheduled task and scheduled it to run against the ‘Maintenance Mode All Computers” Group which is really based on a dynamic formula that simply states: “Object is Microsoft Windows Computer” = True.

    All 500 servers go into maintenance mode.

    Then one day someone told me that they need their particular server in maintenance mode at a different time! Why would anyone want to have their servers go into maintenance mode at a different time?  

    So the dilemma: How to make this all dynamic and not manually explicit.

    Group creation can explicitly exclude individual objects.

    Group creation cannot reference membership of one group and dynamically exclude it. This is quite a problem.

    So then I though there must be a way create to a class with an expression that weeds out unwanted servers that need to be in a different maintenance schedule.

    One thing is true. All servers that need to be in alternate maintenance schedules will enjoy the benefit of having their own hosted class.

    Therefore, I have a created a hosted (registry type) class that identifies the servers that need to have a different maintenance window:






         <Path>SYSTEMCurrentControlSetControlSession ManagerEnvironmentDFC_ServiceUTS</Path>


















           <XPathQuery Type="String">Values/UTSCheck</XPathQuery>




           <Value Type="String">True</Value>





    Now how do I create a class that contains all my servers minus the UTS servers?

  2. Nick M says:

    Excellent script Boris – just a quick question, does the group need to be based on the Windows Server object, or can it be any subset? For example, a dynamic list based on Logical disks?

  3. borisyan says:

    I dont think you can exclude a group from another group’s definition. What you can do is create another class and create a discovery for this class (instances of this class would be the onces that need to go in MM at the same time). Then include only this class in the group.

  4. geist_23 says:

    "Then include only this class in the group."

    Ultimately, this would fail me as inevitably server instances will be a part of more than one class that I define for maintenanec mode.

  5. Check out Boris Yanushpolsky&#39;s blog ( ). Boris is an SCOM

  6. &#160; Voici une liste de liens trés pratique sur tous les sujets SCOM , installation , configuration…

  7. Mark Wolzak says:

    Our servicedesk is using an adapted version of the GroupMaintenancemode -script from Boris Yanushpolski