When Microsoft changed their Windows Update model into the current rollup approach it was awesome from a simplicity standpoint for Admins but one of the costs of that convenience is the increased disk space the updates take up on machines. It got a little annoying when every month around 3am or so, our on-call would get paged due to the Help Desk receiving an alert from Solarwinds due to a server falling below the percentage threshold for free disk space.
I found a great solution on the Microsoft TechNet forums in the form of a script that would clear all update cache older than 7 days. Unfortunately, the forums are no more and I can’t find the script online anymore to give the author credit. This is NOT my work.
At first, I ran the script manually the day before our monthly patching would begin. Then we became a ControlUp customer. That was a game changer. Rather than being reactive to clear space or trying to be proactive with monthly manual intervention, I put the script into action as a ControlUp Automated Action. No more 3am wakeups because I forgot to clear space ahead of patching. Bliss!
In the above video, you can see an example of how I set the script to run when one of my Citrix management servers gets to 4GB or less of free space on the system drive. In my environment with how the cache was configured by the Microsoft Endpoint Configuration Manager admins, when I ran the script it cleared about 7GB of space each time I ran it! On management servers that you size only for the role they play this could be hugely significant and it proved very valuable for us. You can find the script HERE.
Remember how I said before I had ControlUp, I would run the script monthly before patches were deployed?
I don’t work for the hospital anymore but something I could do now is set the script to run on a set schedule using ControlUp’s new Scheduled Trigger. I could simply set a trigger for the management servers in my pilot device collection and another for my production device collection and set the each to run the script the day before my Automatic Deployment Rules are set to fire off the patch deployments. Making my patch cleanup automatic on a scheduled and truly proactive. You can find the script in the ControlUp script library within the Real-Time DX Console and on ControlUp.com. If the original script author reads this, please reach out so I can give you credit.
Photo by Ayoola Salako on Unsplash