QuickTricks: One line PowerShell to remove all objects from maintenance mode | Quisitive
QuickTricks: One line PowerShell to remove all objects from maintenance mode
July 22, 2014
Cameron Fuller
Are you looking for quick ways to see what is in maintenance mode and get them back out of maintenance mode?

This blog post goes through the following:

  • What is currently in maintenance mode?
  • Removing all objects from maintenance mode

What is currently in maintenance mode?

To see what is currently in maintenance mode the following two approaches are available. The first option is not as usable from an output perspective but works well when removing items from maintenance mode. The second shown below provides a more readable format.

Get-SCOMMaintenanceMode

Get-SCOMMonitoringObject | where-object {$_.InMaintenanceMode -eq $true}

Removing all objects from maintenance mode

The following single line PowerShell script will take any objects currently in maintenance mode and remove them from maintenance mode:

Get-SCOMMaintenanceMode | Set-SCOMMaintenanceMode –EndTime (Get-Date) –Comment “Autoremoved from maintenance mode”

The graphic below shows how the PowerShell script runs when removing all items from maintenance mode and the results of re-checking what is in maintenance mode using the Get-SCOMMaintenanceMode command (no results indicating that there are no longer any objects which are in maintenance mode in this management group).