Partager via


Config Mgr maintenance tasks - Powershell to Document, Disable and Re-enable for site upgrades

When running an in-place upgrade to System Center Configuration Manager you should document the status and disable maintenance tasks so they will not run during the site upgrade.

/en-us/sccm/core/servers/deploy/install/upgrade-to-configuration-manager

In a small environment with one or two sites this is pretty easy and can be documented using Powershell or even a screen shot. After the site upgrade is complete the maintenance tasks can be re-enabled. In a large environment that has more sites you may want to look at automating the process of documenting current status, disabling tasks, and then re-enabling after the upgrade is complete.

This script can be run from the CAS, primary site server or any system with the Configuration Manager console installed, it will perform the following actions:

1) Document and disable all maintenance tasks
When the script is run with no parameters it will document current maintenance task status in an xml file and disable maintenance tasks in all Configuration Manager sites.
File Location:     C:\CM-MaintenanceTasks-$date.xml

Now that all maintenance tasks have been documented and disabled we can schedule and complete the Configuration Manager upgrades for all sites. Once the upgrade is complete we can use the script to re-enable the maintenance tasks based on documented values in the CM-MaintenanceTasks-$data.xml file

2) Re-enable all site maintenance tasks
Run script with parameter -enabletasks 1
Example:
.\CMMaintenance.ps1 -enabletasks 1

This will open a file explorer window to allow you to choose the xml file to import. Choose the xml file that was created in step 1 by opening C:\CM-MaintenanceTasks-$date.xml.  When executed the script will re-enable maintenance tasks based on the documented status of the task in the xml file.

The script can be downloaded here:

https://gallery.technet.microsoft.com/scriptcenter/Disable-and-Re-enable-38ae7514

 

Thanks to Kevin Kasalonis for assistance with the idea and script

https://blogs.technet.microsoft.com/cmpfekevin/