New-CMMaintenanceWindow

Create a maintenance window for a collection.

Syntax

New-CMMaintenanceWindow
   [-ApplyTo <MaintenanceWindowApplyTo>]
   [-ApplyToSoftwareUpdateOnly]
   [-ApplyToTaskSequenceOnly]
   [-InputObject] <IResultObject>
   [-IsEnabled <Boolean>]
   [-IsUtc <Boolean>]
   -Name <String>
   -Schedule <IResultObject>
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-CMMaintenanceWindow
   [-ApplyTo <MaintenanceWindowApplyTo>]
   [-ApplyToSoftwareUpdateOnly]
   [-ApplyToTaskSequenceOnly]
   [-CollectionId] <String>
   [-IsEnabled <Boolean>]
   [-IsUtc <Boolean>]
   -Name <String>
   -Schedule <IResultObject>
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-CMMaintenanceWindow
   [-ApplyTo <MaintenanceWindowApplyTo>]
   [-ApplyToSoftwareUpdateOnly]
   [-ApplyToTaskSequenceOnly]
   [-CollectionName] <String>
   [-IsEnabled <Boolean>]
   [-IsUtc <Boolean>]
   -Name <String>
   -Schedule <IResultObject>
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

Use this cmdlet to create a maintenance window for a collection. Maintenance windows are recurring periods of time when the Configuration Manager client can run tasks. For example, apply software updates or install software. This window makes sure that significant system changes only happen at times that don't affect productivity and uptime.

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: Create a maintenance window

The first command uses the New-CMSchedule cmdlet to create a schedule object, and then stores it in the $MWSchedule variable.

The second command creates a maintenance window named MonthlySchedule for the specified collection. The maintenance window uses the schedule stored in the $MWSchedule variable.

$MWSchedule = New-CMSchedule -DayOfWeek Friday -DurationCount 1 -DurationInterval Hours -RecurCount 1 -Start "10/12/2013 21:00:00"
New-CMMaintenanceWindow -CollectionId "XYZ0005D" -Name "MonthlySchedule" -Schedule $MWSchedule

Example 2: Copy a maintenance window between collections

The first command gets a maintenance window from the collection with ID XYZ0003F. It then creates a maintenance window on the collection with ID XYZ0005D with the same name, same schedule, and only for software updates.

$mw1 = Get-CMMaintenanceWindow -CollectionId "XYZ0003F" -MaintenanceWindowName "nightly SUM window"
New-CMMaintenanceWindow -CollectionId "XYZ0005D" -Name $mw1.Name -Schedule (Convert-CMSchedule -ScheduleString $mw1.ServiceWindowSchedules) -ApplyTo SoftwareUpdatesOnly

Parameters

-ApplyTo

Specify the type of maintenance window to create:

  • Any: The maintenance window applies to all deployments.
  • SoftwareUpdatesOnly: The maintenance window only applies to software update deployments.
  • TaskSequencesOnly: The maintenance window only applies to task sequence deployments.

If you don't specify this parameter, Any is the default.

Type:MaintenanceWindowApplyTo
Accepted values:Any, SoftwareUpdatesOnly, TaskSequencesOnly
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ApplyToSoftwareUpdateOnly

This parameter is deprecated. Use the ApplyTo parameter with the SoftwareUpdatesOnly value.

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

This parameter is deprecated. Use the ApplyTo parameter with the TaskSequencesOnly value.

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

Specify the ID of a collection to add the maintenance window. 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 the name of a collection to add the maintenance window.

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

Add this parameter to prompt for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
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 an object for a collection to add the maintenance window. 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
-IsEnabled

To create a maintenance window on a collection, but not have it active, set this parameter to $false. If you don't include this parameter, this cmdlet enables the maintenance window.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-IsUtc

To configure the maintenance window schedule to use Coordinated Universal Time (UTC), set this parameter to $true. If you don't include this parameter, the schedule uses local time.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Name

Specify the name of the maintenance window.

Type:String
Aliases:MaintenanceWindowName
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Schedule

Specify a schedule object for when the maintenance window occurs. To get this object, use the New-CMSchedule cmdlet.

The maintenance window object stores the schedule as a token string. To copy a schedule from another object, use the Convert-CMSchedule cmdlet. For example, Convert-CMSchedule -ScheduleString $mw1.ServiceWindowSchedules.

Type:IResultObject
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet doesn't run.

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

Inputs

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

Outputs

IResultObject

Notes

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