Over time Software Update Packages (read Deployment Packages, but with a proper name) most of the time are filled with unwanted Software Updates if no regular maintenance is performed, leading to unwanted Software Update content taking up unnecessary disk space. I’ve previously created a script to remove expired and superseded Software Updates from a Software Update Group that also removes the content. For most cases using this script or console extension is sufficient. But in some cases, you might have to attack the problem from another angle. In this post I’ll share a script that I’ve created for a good friend of mine that will clean up a Software Update Package from Software Updates that meets the criteria passed to the script.
Download the script
You can download the script from the following link:
Version 1.0.0 of the script contains requested features such as capabilities to be able to remove Software Updates that are either not deployed or was not required by any systems according to scan data. Since ConfigMgr environments never look the same, and different scenarios present themselves, the two main features of the script can selectively be chosen when the script is invoked, catering for different usage scenarios:
- Remove Software Updates that are not deployed
- Remove Software Updates that are not required on any systems
In future version, I’ll add additional capabilities, and if wanted from the community it could be turned into a console extension.
Use the script to clean a Software Update Package that contains Software Updates matching any or all of the criteria mentioned above. Below is an example of a Software Update Package that contains a set of Software Updates that match both criteria:
Follow the instructions below to run the script:
Before you can run the script, you’d need to identify the PackageID value of the Software Update Package you want to clean up. Use the value of the package and pass it to the -PackageID parameter.
- Download the script from GitHub and place it on e.g. C:\Scripts.
- Open an elevated PowerShell console and browse to where you saved the script.
- Run the following command (remember to change the parameter values to suite your environment):
.\Clean-CMDeploymentPackage.ps1 -SiteServer CM01 -PackageID P0100067 -NonDeployedUpdates -NonRequiredUpdates -ShowProgress -Verbose
By using the -ShowProgress and -Verbose switches with the script, you’ll get an overview of the current progress together with detailed information regarding what the script is actually doing.
When the script has executed successfully and completed, the Software Update Package will no longer contain the Software Updates that got removed:
A lot of the links on this page are now broken. Specifically the Microsoft Gallery links that you’ve posted.
Ignore this, I had two many tabs open. I was linked here from this page:
And meant to post the same thing on there.
Even with “-NonDeployedUpdates”, it is deleting anything with 0 required even if it is currently deployed.
This is great. Can’t believe they didn’t provide a more direct/easy way of doing this. Thanks Nickolaj!
I can. It’s the Microsoft way of doing things. It’s disappointing to see this is where we are 15+ years after the start of SMS.
Are there plans to put in whatif capability?
If I’m not mistaken that should be in the newly released 1.0.1 version of the script.
Yes, you’re right! Thanks!
This is simply fantastic. I was able to reduce my update packages by many GBs with this and it worked flawlessly. Thank you so much for your contributions to this community!
Run using ConfigMgr CB 1806 for others wondering.
This Script works just Great! (v1802). Just what i needed! Thank you so much!!
Hi Nikolaj, I was wondering if you had any trick to disable/hide/delete all those updates prior to 1803 in the ‘All Software Updates’ like w10 1507,1511,1607,1703,1709. It becomes a little bit to crowded 🙂
Works the script in SCCM 1710 as well?
It should yes.
[…] https://msendpointmgr.com/2017/08/17/clean-software-update-packages-in-configmgr-with-powershell […]
is there a script which i can use for WSUS. its killing my hard drive space.
Working very nice, saved alot of space after running this. Thanks