SCOM Maintenance exe

hello All,

I would like to know if there is any .exe for putting the SCOM servers in Maintenance mode.(In Future date). 

Any pointers would be great. 

I have a list of servers which would go to MM in SCOM 2012 R2 in future and the timings are random. 

Regards.

September 10th, 2015 4:30am

Hi

In the current version you can schedule maintenance mode via PowerShell or the SDK and there are 3rd party options:

http://blogs.technet.com/b/momteam/archive/2012/05/23/kb-understanding-operations-manager-maintenance-mode.aspx

http://blogs.technet.com/b/stefan_stranger/archive/2012/07/06/put-om2012-computer-group-members-in-maintenance-mode-with-powershell.aspx

Going forward, the current technical previews of the next versions of SCOM have scheduled maintenance mode via the console.

Cheers

Graham

Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 4:41am

See if you can find this script useful, just place servers line by line in ServerList.txt and run this PS from same location where you have placed this file, specify parameters as mentioned below.....

param([int32]$TimeMin, [string]$Reason, [string]$Comment)

Try
{
$api = new-object -comObject 'MOM.ScriptAPI'

Import-Module operationsmanager
New-SCOMManagementGroupConnection

$Servers = Get-Content "ServerList.txt"

$Time = (Get-Date).Addminutes($TimeMin)

Foreach ($Server in $Servers)

{

#Get Computer instance
$ComputerClass = Get-SCOMClass -Name Microsoft.Windows.Computer
$ComputerClassInstance = Get-SCOMClassInstance  -Class $ComputerClass | Where {$_.DisplayName -eq $Server}

If ($ComputerClassInstance -ne $Null)

{

$HealthServiceWatcherClass = Get-SCOMClass -name:Microsoft.SystemCenter.HealthServiceWatcher

#Get Health Service Watcher Class instance of the server
$HSWClass = Get-SCOMClass -Name Microsoft.SystemCenter.HealthServiceWatcher
$HSWClassIns = Get-SCOMClassInstance  -Class $HSWClass | Where {$_.DisplayName -eq $Server}

#Starting the maintenance mode

Start-SCOMMaintenanceMode -Instance $HSWClassIns -EndTime $Time -Reason $Reason -Comment $Comment

Start-SCOMMaintenanceMode -Instance $ComputerClassInstance -EndTime $Time  -Reason $Reason -Comment $Comment

Write-Host "Health Service Watcher and Agent server "$Server " kept in maintenance mode"  -foregroundcolor "green"

#Logging success event
$api.LogScriptEvent('MaintenanceModeScript.ps1', 200, 0, "$Server kept in maintenance mode for $TimeMin minutes")

}

Else

{

Write-Host $Server" not found in your domain " -foregroundcolor "red"

#Logging error event
$api.LogScriptEvent('MaintenanceModeScript.ps1', 101, 1, "$Server could not be found in your domain")

}

}
}

Catch [system.exception]

{

$api.LogScriptEvent('MaintenanceModeScript.ps1', 101, 1, $_.Exception.Message)

}

September 10th, 2015 4:31pm

Hi

May I ask why are you putting the health service watcher into maintenance mode? With SCOM 2012 R2, putting the computer object into maintenance mode automatically puts the health service into maintenance mode as well. There is no need for the additional code.

Also, the code you post isn't cluster aware. I'd suggest this to the original poster:

http://marcelzehner.ch/2013/11/07/scom-2012-put-cluster-node-and-cluster-object-in-maintenance-mode/

Regards

Graham

Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 4:54pm

Thanks Graham,

Refering to https://support.microsoft.com/en-us/kb/942866 I have considered putting HS under maint mode, this looks to be still applicable for SCOM 2012, please confirm

September 11th, 2015 7:03am

I had to automate it using SCO. 

Read the date timestamp. If the diff is less than 5 mins. Execute MM script against the servername. 

Regards.

Free Windows Admin Tool Kit Click here and download it now
September 15th, 2015 12:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics