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.
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