Open SCOM (System Center Operations Manager) console to start a Maintenance Mode could be slow when you are in a large environment.
So, I made my own SCOM console for the Maintenance Mode.
In this SCOM Maintenance Mode GUI tool, you can search for Windows servers. The input supports wildcard search. It will list all servers on SCOM if you leave the name blank.
First, select a server on the list. You can only start maintenance mode on one server at a time.
Then, enter a duration time (5 minutes minimum) or select a specific end time. If you enter the duration time, the end time will be the current time plus the duration time.
If you have both duration time and specific end time, specific end time will overwrite the duration time.
You might notice the form looks different when you select a specific end time. This is because the main form was created by WPF (Windows Presentation Foundation), but there is no DateTimePicker in WPF. There is an Extended WPF Toolkit for DateTimePicker that works on Visual Studio, but I could not make it work on PowerShell.
Windows Forms have a built-in DateTimePicker, so I created a separate form for it.
The default Maintenance Mode Reason is Other(Planned). Comment is not required.
It will prompt you after click Start Maintenance Mode button. Click OK to start the maintenance mode.
To stop the maintenance mode, select the Stop Maintenance Mode tab. Select the server and click the Stop Maintenance Mode button.
You can download the script from GitHub.
The script needs to be executed by the account that has privilege in SCOM.
Add-Type -AssemblyName PresentationFramework Add-Type -AssemblyName System.Windows.Forms # SCOM Management Server Input #$SCOMMgmtSvr = "YourManagementServer.yourDomainName" $SCOMMgmtSvr = Read-Host "Please enter your SCOM Management Server name" New-SCOMManagementGroupConnection -ComputerName $SCOMMgmtSvrYou can enter the SCOM Management Server name after running the script on the PowerShell console.
Or, add the server name on line 5 and comment out line 6 in the script.
Tested platform: SCOM 2012 R2, Windows Server 2012 R2, PowerShell v4.0
Update 01/03/2018 :
SCOM 2012 R2 is not able to schedule a Maintenance Mode for a server. The feature has been added to SCOM 2016. However, we are not ready to upgrade yet. So I decide to add the feature to my GUI tool.
Using PowerShell Scheduled jobs, I am able to create a PowerShell job that running the Start-SCOMMaintenanceMode cmdlet on demand. Below is the main function code.
$trigger = New-JobTrigger -Once -At $startTime $cred = Get-Credential $userID $options = New-ScheduledJobOption -RequireNetwork $script = { Import-Module -Name OperationsManager New-SCOMManagementGroupConnection -ComputerName $args[2] $instance = Get-SCOMClassInstance $args[0] Start-SCOMMaintenanceMode -Instance $instance -EndTime $args[1].ToUniversalTime() # Remove Scheduled Job Unregister-ScheduledJob -Name $args[0] } Register-ScheduledJob -Name $selectedItem -ScriptBlock $script -Trigger $trigger -ScheduledJobOption $options -Credential $cred -ArgumentList $selectedItem, $time,$SCOMMgmtSvrWhen you Register-ScheduleJob, it creates a PowerShell job that will be triggered by the Windows Task Scheduler. The Task Scheduler can be found in Task Scheduler Library -> Microsoft -> Windows -> PowerShell -> ScheduledJobs.
You can also hide the task scheduler by adding New-ScheduledJobOption -HideInTaskScheduler.
The scheduled job does not remove after it completed. So I added the Unregister-ScheduledJob to the script after started the maintenance mode.
It`s very easy to use. You just need to select the start time and end time for the maintenance mode. You will need the domain account credential with SCOM privilege.
The scheduled jobs will show in the Scheduled Maintenance Mode tab.
Please test the script in the DEV environment before you use it in Production. You can download the script from GitHub.
Remember to change the SCOM Management Server variable before you run it.