Configuration PowerShell SCOM System Center Tool

SCOM 2016 – Start-SCOMAgentMaintenanceMode PowerShell Way

MaintenanceMode

In SCOM 2016 there is a new way to set maintenance mode on your agent machine itself. Microsoft released a module to set the maintenance mode on the agent server itself. It uses a library (MaintenanceMode.dll) to set maintenance mode parameters on your monitored server. This DLL can be found in the C:\Program Files\Microsoft Monitoring Agent\Agent directory. After you executed the commands it will write some registry settings and after that, a rule in SCOM will pick these settings up and set the corresponding maintenance window in SCOM.  If you want to read more details, please check this blog post from Natascia Heil.

The Problem

This approach is a very nice way of doing maintenance mode, BUT there are some pains involved with this implementation. For example if you start to set a maintenance window, you will need to confirm each time to approve your request.

image

Let’s say you want to use a scheduled task and the Microsoft module to schedule a maintenance mode. Because the confirmation dialog is hardcoded it will be tricky to skip that confirmation. In addition it is somewhat limited, like resetting the maintenance mode settings (deleting the maintenance mode registry key) has to be done manually.

The Solution

If have reverse engineered the DLL and created a PowerShell module to achieve the exact same functionality with the identical syntax and command. I added also a command to delete the maintenance settings (registry key) on the agent machine.

Install the module via PowerShell Gallery

image

…then import the module and set the parameters…

image

…to delete the registry key use the following command…

image

As I mentioned before, it works exactly the same way as Microsoft describes in the TechNet article. But, except we can use this module to use in scheduled tasks and delete the settings via module.

Download the PSMaintenanceMode Module here.

If you have any questions, let me know. I hope this helps.

2 Replies to “SCOM 2016 – Start-SCOMAgentMaintenanceMode PowerShell Way

  1. Could it be that this feature is not working with SCOM 1801? We had it running when using SCOM 2016 but after the 1801 update it is not working anymore. I saw that the rule “Agent Initiated Maintenance Mode Rule” is not enabled by default anymore with 1801. But even re-enabling it does not fix the problem. The 2222 event is created after re-enabling the rule but the follow up 1215 event is not coming up. So I guess I missed something else to re-enable here. Do you have any ideas here?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.