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:
Script documentation
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.
Usage
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:
(19399)

Chief Technical Architect and Enterprise Mobility MVP since 2016. Nickolaj has been in the IT industry for the past 10 years specializing in Enterprise Mobility and Security, Windows devices and deployments including automation. Awarded as PowerShell Hero in 2015 by the community for his script and tools contributions. Creator of ConfigMgr Prerequisites Tool, ConfigMgr OSD FrontEnd, ConfigMgr WebService to name a few. Frequent speaker at conferences and user groups.
Fredrik
Working very nice, saved alot of space after running this. Thanks
Santhosh Basavarajappa Shakuntala
is there a script which i can use for WSUS. its killing my hard drive space.
Heiko
Works the script in SCCM 1710 as well?
Nickolaj Andersen
It should yes.
Regards,
Nickolaj
Michael
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 š
Pascal
This Script works just Great! (v1802). Just what i needed! Thank you so much!!
John
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.
Adam
Are there plans to put in whatif capability?
Nickolaj Andersen
Hi Adam,
If I’m not mistaken that should be in the newly released 1.0.1 version of the script.
Regards,
Nickolaj
Adam
Yes, you’re right! Thanks!
Andrew
This is great. Can’t believe they didn’t provide a more direct/easy way of doing this. Thanks Nickolaj!
Rich
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.
Bjorn
Even with “-NonDeployedUpdates”, it is deleting anything with 0 required even if it is currently deployed.