Set-SCOMMaintenanceMode

Updates active maintenance mode entries.

Syntax

Set-SCOMMaintenanceMode
   [-MaintenanceModeEntry] <MaintenanceWindow[]>
   [-PassThru]
   [-EndTime] <DateTime>
   [[-Comment] <String>]
   [[-Reason] <MaintenanceModeReason>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Set-SCOMMaintenanceMode cmdlet updates active maintenance mode entries. You can use this cmdlet to update only active entries.

When a resource is in maintenance mode, System Center 2016 - Operations Manager suppresses alerts, notifications, rules, monitors, automatic responses, state changes, and new alerts.

You can change the comment or reason for the maintenance mode. Use the Get-SCOMMaintenanceMode cmdlet to get a maintenance mode entry to update. Specify an end for the maintenance window.

Examples

Example 1: Update active maintenance mode entries for resources in a domain

PS C:\>$NewEndTime = (Get-Date).addDays(1)
PS C:\> Get-SCOMClassInstance -Name "*.Contoso.com" | Get-SCOMMaintenanceMode | Set-SCOMMaintenanceMode -EndTime $NewEndTime -Comment "Updating end time."

This example updates all active maintenance mode entries for a specified domain. The first command creates a DateTime object for one day in the future and then stores it in the $NewEndTime variable.

The second command gets all class instances in the Contoso.com domain and uses the pipeline operator (|) to pass the class instance objects to the Get-SCOMMaintenanceMode cmdlet, which gets maintenance mode entry objects. The command uses the pipeline operator to pass these objects to the Set-SCOMMaintenanceMode cmdlet. This cmdlet updates the end time for each object to the DateTime object stored in the $NewEndTime variable. The command also includes a comment for each updated maintenance mode entry.

Example 2: Update maintenance mode entry for a specified resource

PS C:\>$Instance = Get-SCOMClassInstance -Name "Server01.Contoso.com"
PS C:\> $MMEntry = Get-SCOMMaintenanceMode -Instance $Instance
PS C:\> $NewEndTime = (Get-Date).addMinutes(30)
PS C:\> Set-SCOMMaintenanceMode -MaintenanceModeEntry $MMEntry -EndTime $NewEndTime -Comment "Adding 30 minutes to the end time."

This example extends maintenance mode for a specified server. The first command gets the class instance named Server01.Contoso.com and then stores it in the $Instance variable.

The second command gets the maintenance mode entry for the class instance stored in the $Instance variable and stores the entry in the $MMEntry variable.

The third command creates a DateTime object for 30 minutes in the future and then stores it in the $NewEndTime variable.

The fourth command updates the maintenance mode session for the maintenance mode entry stored in the $MMEntry variable to the DateTime object stored in the $NewEndTime variable and adds a comment.

Required Parameters

-EndTime

Specifies when maintenance mode ends as a DateTime object. A resource cannot be in maintenance mode for fewer than five minutes. To obtain a DateTime object, use the Get-Date cmdlet. For more information, type Get-Help Get-Date.

Type:DateTime
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-MaintenanceModeEntry

Specifies an array of MaintenanceWindow objects. To obtain a MaintenanceWindow object, use the Get-SCOMMaintenanceMode cmdlet.

Type:MaintenanceWindow[]
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional Parameters

-Comment

Specifies a comment for the maintenance mode entry.

Type:String
Position:3
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-PassThru

Indicates that the cmdlet creates or modifies an object that a command can use in the pipeline. By default, this cmdlet does not generate any output.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Reason

Specifies a reason for maintenance mode. The acceptable values for this parameter are:

  • PlannedOther
  • UnplannedOther
  • PlannedHardwareMaintenance
  • UnplannedHardwareMaintenance
  • PlannedHardwareInstallation
  • UnplannedHardwareInstallation
  • PlannedOperatingSystemReconfiguration
  • UnplannedOperatingSystemReconfiguration
  • PlannedApplicationMaintenance
  • ApplicationInstallation
  • ApplicationUnresponsive
  • ApplicationUnstable
  • SecurityIssue
  • LossOfNetworkConnectivity
Type:MaintenanceModeReason
Position:4
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False