Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 34890

Place A Server Into Maintenance Mode From That Server without a Console – Start-MaintenanceMode.ps1

$
0
0

One if the greatest things about working for a company like Microsoft is the number of people that work together to discuss, identify and solve problems. For this particular problem was just four of us ( Jeramy Evers, Mark Trammell, Paul Ray and myself ) discussing a better solution for administrators to place their servers in Maintenance Mode while they are on the server about to perform some type of work. Yes, yes I know there are plenty of scripts out there already that do something like this, but if there is a SCOM Agent already installed on it and it is healthy, then why not place it into Maintenance Mode from the server?

Here is is solution we came up with:

I am going to place this server into Maintenance Mode:

image

First we loaded the “Start-MaintenanceMode.ps1” either on the desktop or in a location that everyone has access to, or at least the system / application administrators. If you right click on the script and “Run with PowerShell”

image

When the PowerShell window pops open, it may ask you to change the “Execution Policy”. select “Y” if you would like to continue with setting the system in Maintenance Mode

image

When the “SCOMManagementServerName:” appears, enter one of the management servers.

image

The next thing that appears is the “Minutes:”, enter the amount of time you would like to place the system in Maintenance Mode. Note that you cannot place a system in maintenance mode less than 5 minutes.

image

If you see the following message, you shouldn’t worry to much since the script will call out and import the “operationsmanager” module.

image

If I go back to my Console I will see the system in Maintenance Mode

image

That is it.

If you want to require people to provide comments each time they place a system, you can change the “$False” to “$True” for line 56.

image

Pretty simple, you can download the script here.

This script has been tested and works fro SCOM 2012 R2 and SCOM 2016.





Viewing all articles
Browse latest Browse all 34890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>