Overview
Microsoft System Center Operations Manager SP1 (SCOM) is a Microsoft-launched professional system monitoring software that monitors servers, applications, and clients deployed on the network, providing a graphical view Enables administrators to monitor failures and warnings that occur on the target computer.
Reference article: http://www.scom2k7.com/scom-2012-maintenance-mode-scheduler/
PowerShell script Settings scom Maintenance Mode (Maintenance mode)
1. Setting up Maintenance mode
$MachineName = "a. b. Local"
# Get the power of classes for all SCOM components
Get-scomclass-name "*windows*" | Get-scomclassinstance
# Get an instance of the SCOM Component Class named $MachineName
$Instance = Get-scomclassinstance-name $MachineName
# Set maintenance time to last ten minutes
$Time = ((get-date). AddMinutes (10))
# Set Maintenance mode
Start-scommaintenancemode-instance $Instance-endtime $Time-comment "Applying NCover Maintenance Job"-reason "PlannedA Pplicationmaintenance " -erroraction silentlycontinue
2. View the status of the specified instance
Get-scommaintenancemode-instance $Instance
3. End Maintenance Mode
# Add SCOM plugin
Add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"
# Set the current work session to Scom
Set-location "operationsmanagermonitoring::"
# Specify the machine name of the current Oprmanagerserver
$rmsServerName = "opr. b. Local "
#
#测试管理组连接是否正常, administrative groups can change
$mgConn = new-managementgroupconnection-connectionstring: $rmsServerName
if ($mgConn-eq $null)
{
[String]::format ("Failed to connect to RMS on ' {0} '", $rmsServerName)
Return
}
# Set the current work session to the Scom Management console server
Set-location $rmsServerName
# Set the end time of maintenance mode, after 5 seconds
$time = ((get-date). AddSeconds (5))
#通过agent获取Monitoringobject
$agent = get-agent|where {$_.name-eq $MachineName }
$server = $agent. Hostcomputer
Set-maintenancewindow-monitoringobject $server-endtime $time
Wait 5 minutes .
Play the third section of PowerShell-"SCOM maintenance Mode"-Technology & Sharing