Just uploaded my first contribution to SUP/WSUS maintenance and recommendations to TechNet gallery.



2017-10-10 003737

The package will automatically configure maintenance jobs for your SUP/WSUS/CM database and check recommendations and requirements for WSUS/SUP.

It will configure jobs to run a weekly re-index, defrag of the databases (with the help of Ola Hallengren) and a cleanup of WSUS. The scripts also checks/configures recommendations and requirements for SUP/WSUS, i.e. check for KB3095113 and required system rights.

This version of the scripts does only support one server setup, where SUP, WSUS and ConfigMgr are installed on the same server.

If you need another configuration or have other contributions make a comment, send me an email or tweet me.


Before you run the scripts

Make sure no Software update synchronization is running at the same time as the scheduled jobs – From Saturday 5 AM to how long it takes for you jobs to run.

To minimize the risk I usually configures Software Update synchronization Weekly at Wednesday at 2 AM, if Endpoint protection is in used run the Synchronization daily at the same time and make sure it is done at 5 AM – else tweak the time!

After you performed the installation of the scripts, I recommend to run the scripts manually the first time. This can take hours, and hours, I have seen it running for a day or two. Sometimes it will fail, then you need to run it a couple of times (if WSUS cleanup cannot be made, use the last resort script to cleanup the WSUS database directly). Remember if you have never run this before it will take hours, hours and probably some more hours – have patience. When you done manually once and everything succeeded, do it again until you see it is rather “quick”.

Keep in mind to disable SUP synchronization when you run it manually. Also try to not run this the first time during normal working hours, depending on your hardware configuration it may peek your disk, CPU and memory.

Procedure to run the scripts

10 Check Pre-Requirements.ps1 – Run this with administrative permissions and it will make sure all the pre-req and recommendations are in place. It will do the changes and tell you what it has changed.

20 Configure Services.ps1 – Run this with administrative permissions and it will configure SQLSERVERAGENT to run automatically and make SQL Agent service account member of WSUS Admins and local admin to run all the jobs

30 Installation.sql – This will create a database to store history data

40 MaintainaceSolution.sql – This is Olas script from the top to bottom, the only change is where to store the history data

50 Schedule MaintainaceSolution.sql – This will schedule Olas scripts above, IT WILL NOT ENABLE BACKUP! Weekly saturday at 5 AM and 7 AM

60 WSUS Cleanup Task Scheduled.sql – This will schedule WSUS maintenance Monthly at the first Saturday at 5 PM


I hope you don’t need this, but there is a way to clean up the updates from the database directly.

99 Last Resort – Cleanup updates.sql  – as it states use at last resort and if this fails – reinstall WSUS with a clean database


These scripts are built upon my own experience and other reliable sources