Sometimes it's hard to accommodate all needed packages in SCCM cache, so admins usually increase the size of the cache to a few gigabytes. Since SCCM does not clean cache unless it needs to fit some new packages, you will end up with old versions of packages and some not really used stuff there.

Here is a script, that will increase the cache to 20GB, find all non-referenced versions (old packages, pretty much), it will also find packages, that have not been used in last 7 days (configurable) and delete them from the client cache.

It also includes two reports, one shows computers and how much space was saved, another a summary report, that shows a total of how much was saved, average and a number of computer that ran it.

Enjoy!