Manage SCCM Maintenance Windows with Powershell

Benoit LecoursPowershell, SCCM1 Comment

If you’re not aware, you can manage your SCCM maintenance Windows using PowerShell.

Here’s a simple example but you can get creative.

#Import SCCM Module
Import-Module $env:SMS_ADMIN_UI_PATH.Replace(“bini386″,”binconfigurationmanager.psd1”)

#Get SiteCode
$SiteCode = Get-PSDrive -PSProvider CMSITE

# Set Location to SCCM
Set-Location “$($SiteCode.Name):”

#Occurs Fourth day of every 3 months effective the time you create it at 3:00 AM
$Schedule = New-CMSchedule -DurationCount 1 -DurationInterval Hours -RecurCount 3 -DayOfMonth 4 -Start ([Datetime]”3:00″)
$Collection = Get-CMDeviceCollection -Name “Your Collection Name”
New-CMMaintenanceWindow -CollectionID $Collection.CollectionID -Schedule $Schedule -Name “Your Schedule Name”

More information and example on technet @ http://technet.microsoft.com/library/dn472934(v=sc.20).aspx

You can also verify if your maintenance windows has been configured properly in your collections with the report Configuration Manager – Collections.

Simply sort by the maintenance windows column.

maintenance windows reboot SCCM maintenance windows

 

One Comment on “Manage SCCM Maintenance Windows with Powershell”

  1. Hello there,

    I have gone through and created all the MW, with or without Powershell. I have them in a good place, all I want to edit is the day. Our company picks days based on Accounting cutoffs and not patch Tuesday. Some moths we patch on Thursday around the 20th, some days on Saturday. I know the dates well in advance and would like to script changing the date only. Start time comes back with 6/23/2018 5:00:00 AM all I want to change is 6/23/2018 to 12/19/2018 and so on. Thank you very much,
    Ed

Leave a Reply

Your email address will not be published. Required fields are marked *