Get-CMMaintenanceWindow

Get the maintenance windows for a collection.

Syntax

Get-CMMaintenanceWindow
   [-InputObject] <IResultObject>
   [-MaintenanceWindowName <String>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [<CommonParameters>]
Get-CMMaintenanceWindow
   [-CollectionId] <String>
   [-MaintenanceWindowName <String>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [<CommonParameters>]
Get-CMMaintenanceWindow
   [-CollectionName] <String>
   [-MaintenanceWindowName <String>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [<CommonParameters>]

Description

Use this cmdlet to get the maintenance windows for the specified collection. You can also filter the results to a specific maintenance window.

For more information on maintenance windows, see How to use maintenance windows in Configuration Manager.

Note

Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>. For more information, see getting started.

Examples

Example 1: Get enabled maintenance windows for a collection by ID

This command gets the maintenance windows that are enabled for the specified collection.

Get-CMMaintenanceWindow -CollectionID "XYZ0004D" | Where-Object { $_.IsEnabled }

Example 2: Get all maintenance windows for a collection object

This example first gets a collection object, and then passes that on the pipeline to get a maintenance window by its name.

$coll = Get-CMCollection -CollectionID 'XYZ0003F'
$coll | Get-CMMaintenanceWindow -MaintenanceWindowName 'nightly SUM window'

Example 3: Get the schedule for a maintenance window

This example first gets a maintenance window for a specific collection. It then converts the ServiceWindowSchedules property to display the maintenance window's schedule.

$mw = Get-CMMaintenanceWindow -CollectionID "XYZ000AB"
Convert-CMSchedule -ScheduleString $mw.ServiceWindowSchedules

Parameters

-CollectionId

Specify a collection ID to query for its maintenance windows. This ID is a standard collection ID, for example XYZ0003F.

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-CollectionName

Specify a collection name to query for its maintenance windows.

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DisableWildcardHandling

This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.

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

This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.

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

Specify a collection object to query for its maintenance windows. To get this object, use the Get-CMCollection cmdlet.

Type:IResultObject
Aliases:Collection, Site
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-MaintenanceWindowName

Specify the name of a maintenance window on the targeted collection. By default, Get-CMMaintenanceWindow returns all maintenance windows. Use this parameter to filter the results to the specified window name.

You can use wildcard characters:

  • *: Multiple characters
  • ?: Single character
Type:String
Aliases:Name
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:True

Inputs

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

Outputs

IResultObject[]

Notes

For more information on this return object and its properties, see SMS_ServiceWindow server WMI class.