Edit

Share via


Get-CMMaintenanceWindow

Get the maintenance windows for a collection.

Syntax

ByValue (Default)

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

ByCollectionId

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

ByCollectionName

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.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByCollectionId
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-CollectionName

Specify a collection name to query for its maintenance windows.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ByCollectionName
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DisableWildcardHandling

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ForceWildcardHandling

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

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-InputObject

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

Parameter properties

Type:IResultObject
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Collection, Site

Parameter sets

ByValue
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments: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

Parameter properties

Type:String
Default value:None
Supports wildcards:True
DontShow:False
Aliases:Name

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

Outputs

IResultObject

Notes

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