Removing stale cache from the ConfigMgr client

The ConfigMgr client pretty well manages it’s own cache, but sometimes it can leave a little to be desired. For one, it does not account for free space on the machine when you specify the CCMCACHESIZE. This hard codes the maximum size the cache can grow to. In our environment this can be an issue, so I put together a script to clean out all stale packages in the ConfigMgr cache.

This script parses through all the elements of the cache, groups them by Package ID, then grabs the maximum version and removes all other versions. I always like to add a little color so I used write-host (I know) with some corrosponding colors for up to date cache and stale cache.

I also wanted a way to see what the content looked like before deleting it, so I added a -whatif parameter with a default of true. This runs the script like normal but does not actually remove any content.

RemoveStaleCache

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">