Play the third section of PowerShell-"SCOM maintenance Mode"-Technology & Sharing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.