# 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
