PoshCode Archive  Artifact [968d3196d2]

Artifact 968d3196d2d8ada515b5a884ae85df69a9fa867cfba62717af515cf78498e562:

  • File Start-SCOM-Maint-Mode.ps1 — part of check-in [0d49b6ccf3] at 2018-06-10 14:07:14 on branch trunk — Turns on Maintenance Mode for a specific computer monitored by SCOM (System Center Operations Manager). Ensure that the OperationsManager module is available on the computer from which this script is executed. (user: Austin Greca size: 975)

# encoding: ascii
# api: powershell
# title: Start SCOM Maint Mode
# description: Turns on Maintenance Mode for a specific computer monitored by SCOM (System Center Operations Manager).  Ensure that the OperationsManager module is available on the computer from which this script is executed.
# version: 0.1
# type: module
# author: Austin Greca
# license: CC0
# x-poshcode-id: 6060
# x-archived: 2016-05-17T10:47:40
# x-published: 2016-10-21T18:54:00
#
# Example script puts machine into maintenance mode for 15 minutes (adjustable by changing the $time variable).  At the time specified, the machine will come out of maintenance mode automatically.
#
Import-Module OperationsManager

$computer = "mycomputer.mydomain.com"

$time = (Get-date).AddMinutes(15)

$instance = Get-SCOMClassInstance -Name $computer -ComputerName myscommgmtserver

Start-SCOMMaintenanceMode -Instance $instance -EndTime $time -Comment "Applying updates" -Reason PlannedOther