How To Remove Maintenance Windows on Collections in SCCM Via Powershell

Jason Barrett Jason Barrett | | ConfigMgr

Remove Maintenance Windows SCCMIn this article I will show you how you can remove maintenance windows on multiple collections in SCCM via powershell.  This can save you a lot of time if you have multiple windows to remove from multiple collections.

Using powershell in Configmgr you can remove maintenance windows from collections by using the Remove-CMMaintenanceWindow command.

Below I will show you how to create a script to remove multiple maintenance windows at the same time.

Please Be Aware : If you remove a maintenance window and there is a software application / update waiting to install, the software will install as soon as the maintenance window it removed.

How To Check Existing Maintenance Windows

If you want to check what maintenance windows are currently in place for a collection you can use the Get-CMMaintenanceWindow command.  To use this command do the following

  1. Open System Center Configuration Manager
  2. Left click the top arrow and select Connect via Windows Powershell
    configuration manager powershell
  3. In the powershell window type in Get-CMMaintenanceWindow -collectionid %COLLECTIONID% (To get the collection ID browse to the required collection and right click on it and select properties.  The collection ID will be shown at the bottom of the window.
  4. You can also see the maintenance windows via the gui by browsing to the collection ID and right click > properties > Maintenance window tab
    maintenance window

TIP : If you want to check maintenance windows for multiple collections in one go it is much faster to do it via the powershell command.

How To Remove Maintenance Windows on Collections in SCCM Via Powershell

To remove a maintenance window on a collection in SCCM we are going to use powershell with the Remove-CMMaintenanceWindow command.

  1. Collect all the collections IDs you want to remove the maintenance windows for.  To get the collection IDs open Configuration Manager (Configmgr) and browse to Assets and Compliance > Device Collections > Right click on the required collection and click properties.
    SCCM Collection ID
  2. The collection ID will be shown at the bottom of the window, it will start with SC.
  3. In Configuration Manager left click the top arrow and select Connect via Windows Powershell
    configuration manager powershell
  4. Type in Remove-CMMaintenanceWindow -collectionid %COLLECTIONID% -name * -Force This will now remove all maintenance windows with out prompting you
    powershell
  5. Now run Get-CMMaintenanceWindow -collectionid %COLLECTIONID% to make sure the maintenance window has been removed
    sccm maintenance window removed
  6. If you want to remove more than one maintenance window at a time we can create a script to do this.  Open Windows Powershell ISE and paste the command Remove-CMMaintenanceWindow -collectionid %COLLECTIONID% -name * -Force as many times as needed (Replacing %COLLECTIONID% with the correct ID.)
    bulk remove maintenance windows
  7. Save the file making sure it is saved with the .ps1 file extension.
  8. Head over to the powershell window we opened via configuration manager. Type in Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass and hit enter. Select y
    executepolicy
  9. Type in the path of the file we just created
    script
  10. Now run Get-CMMaintenanceWindow -collectionid %COLLECTIONID% to make sure the maintenance window has been removed
    sccm maintenance window removed

If you have any questions on this process please post about it in a comment below.