SCCM Maintenance Window - Daily 9pm to 5am


Use this PowerShell script to add a maintenance window to a collection going from 9pm to 5am


#Set Names
$CollectionName = “Collection Name”
$WindowName = “Daily 9pm to 5am”

#Occurs Every day at 11pm to 5am
$Schedule = New-CMSchedule -Start "01/01/2016 8:55 PM" -DurationCount 8 -DurationInterval Hours -RecurInterval Days -RecurCount 1
$Collection = Get-CMDeviceCollection -Name $CollectionName
New-CMMaintenanceWindow -CollectionID $Collection.CollectionID -Schedule $Schedule -Name $WindowName



Another window that you might want to set is to occur after hours and during the weekend. Here is a script to set that

#Set Names
$CollectionName = "Collection Name"

#Occurs Every day at 5pm to 5am
$WindowName = "Daily 5pm to 5am"
$Schedule = New-CMSchedule -Start "01/01/2016 5:00 PM" -DurationCount 12 -DurationInterval Hours -RecurInterval Days -RecurCount 1
$Collection = Get-CMDeviceCollection -Name $CollectionName
New-CMMaintenanceWindow -CollectionID $Collection.CollectionID -Schedule $Schedule -Name $WindowName

#Occurs Saturday at 4am to 6pm
$WindowName = "Saturday"
$Schedule = New-CMSchedule -Start "01/01/2016 4:00 AM" -DurationCount 14 -DayOfWeek Saturday -DurationInterval Hours -RecurCount 1
$Collection = Get-CMDeviceCollection -Name $CollectionName
New-CMMaintenanceWindow -CollectionID $Collection.CollectionID -Schedule $Schedule -Name $WindowName

#Occurs Saturday at 4am to 6pm
$WindowName = "Sunday"
$Schedule = New-CMSchedule -Start "01/01/2016 4:00 AM" -DurationCount 14 -DayOfWeek Sunday -DurationInterval Hours -RecurCount 1
$Collection = Get-CMDeviceCollection -Name $CollectionName
New-CMMaintenanceWindow -CollectionID $Collection.CollectionID -Schedule $Schedule -Name $WindowName


Sources:

Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.