Skip to Main Content
4 VOTE
Status Future consideration
Categories Efficiency
Created by Rick Bywalski
Created on Jun 2, 2020

Add Remove SCOM Maintenance Mode

My team uses SCCM to manage and patch our servers it would be nice to be able to right click and add or remove a collection from maintenance mode in SCOM. This would help bridge the gap between the two products that has existed for many years and is has been ask for in Microsoft's user voice as well. I have found a management pack that can do the Add part but it falls short when the maintenance finishes early there is no way to remove those machines from maintenance mode easily with out having to get someone from SCOM team involved.

Product Right Click Tools
  • Attach files
      Drop here to upload
    • Michael Lovett
      Reply
      |
      Feb 14, 2025

      This would be very useful, to target also when a reboot is scheduled, to put a Machine in Maintenance Mode by manipulating the Microsoft Monitoring Host Agent, could be done with SCOM PowerShell Module:

      # Import the Operations Manager module

      Import-Module OperationsManager

      # Variables

      $computerName = "YourComputerName"

      $maintenanceModeDuration = 30 # Duration in minutes

      $rebootTime = (Get-Date).AddMinutes(5) # Schedule reboot 5 minutes from now

      # Function to put the machine in maintenance mode

      Function Set-MaintenanceMode {

      param (

      [string]$ComputerName,

      [int]$Duration

      )

      # Get the computer object in SCOM

      $computer = Get-SCOMMonitoringObject -Name $ComputerName

      # Set maintenance mode

      Start-SCOMMaintenanceMode -Instance $computer -EndTime (Get-Date).AddMinutes($Duration) -Reason "PlannedOther" -Comment "Scheduled reboot"

      Write-Host "$ComputerName has been put in maintenance mode for $Duration minutes."

      }

      # Function to schedule a reboot

      Function Schedule-Reboot {

      param (

      [string]$ComputerName,

      [datetime]$RebootTime

      )

      # Schedule a reboot task

      $action = New-ScheduledTaskAction -Execute "shutdown.exe" -Argument "/r /t 0"

      $trigger = New-ScheduledTaskTrigger -At $RebootTime -Once

      Register-ScheduledTask -TaskName "ScheduledReboot" -Action $action -Trigger $trigger -ComputerName $ComputerName -Force

      Write-Host "Reboot scheduled for $ComputerName at $RebootTime."

      }

      # Put the machine in maintenance mode

      Set-MaintenanceMode -ComputerName $computerName -Duration $maintenanceModeDuration

      # Schedule the reboot

      Schedule-Reboot -ComputerName $computerName -RebootTime $rebootTime


    • +1