Close Menu
    Facebook X (Twitter) Instagram
    Saturday, October 11
    X (Twitter) LinkedIn Reddit RSS
    All about Endpoint Management
    • Home
    All about Endpoint Management
    Home»CM2012»SCCM Configmgr 2012 How to clean software updates files only from client ccmcache folder

    SCCM Configmgr 2012 How to clean software updates files only from client ccmcache folder

    Eswar KonetiBy Eswar KonetiNovember 04, 6:15 pm3 Mins Read CM2012 7,622 Views
    Share
    Facebook Twitter LinkedIn Reddit

     

    There are many blog post online ,that discuss about Configuration manager client cache ,how it works, also many questions about content cleanup from ccmcache folder,cache size is increasing beyond the Cachesize limit etc.

    when you install Configuration manager client,by default it choose the cache location as %windir%\ccmcache with default size 5GB unless you explicitly specify.you can read the post about Client Cache from my previous blog here.

    How to change the configuration manager client cache size using script http://eskonr.com/2013/07/script-to-change-sccm-configmgr-change-client-cache-size/

    Recently ,I was monitoring the patch compliance results at my customer and found that ,many of the clients have failed due to low disk space on C drive (default size for ccmcache is 5GB).Yes.what you heard is correct (C drive). Most of the failed Clients are allocated C drive with 40GB (old computers how they setup earlier) .

    image

    If you read above snippet from TechNet article, software updates also uses client cache but they are not restricted by configured cache size which means,software updates can go beyond 5GB and no restrictions for it.

    This issue is fixed in Configuration manager 2012 R2 cumulative update 2 https://support.microsoft.com/en-us/kb/2970177/en-us?wa=wsignin1.0. So make sure you are running min CU2 or above on your Configmgr client to avoid this issue.

    So coming to the issue ,Customer is still running on CU1 (no comments pls) and I have to cleanup the ccmcache folder to get some disk space until Configuration manager clients are upgraded to Min CU2 level.

    CCMCACHE is also used by applications,packages apart from Software updates .In this case,I choose to cleanup software updates only from CCMCACHE folder.

    How to clean software updates files only from client ccmcache folder:

    If you want to cleanup the content which is older than 30 days or 60 days irrespective of packages,applications etc, then use the script from here

    It took little time for me to identify the difference with applications,packages from software updates.Unlike Configmgr 2007,folders in Configmgr 2012 Client cache are named with single letter and it is difficult to say what is application,package and Software update.

    Upon looking at wmi class CacheInfoEx ,namespace Namespace Root\ccm\SoftMgmtAgent ,found what makes the difference with software update file.

    for packages and applications,the contentID starts with Content or PackageID and I used logic  in where condition to get all except these (notlike ‘Content*’ and packageID length not ‘8’ ).

    Below is the script which deletes software update folders from ccmcache folder ,it also pipes the information about what folders being deleted with freed space into C:\windows\temp\cacheremoval.log

    You can polish the script to make it better way .

    You can deploy this script via Configmgr 2012 by creating legacy package,program and deploy to collection.

    #Title:Delete Software update folders from ccmcache folder on Configmgr 2012 Client
    #Author:Eswar Koneti
    #dated:06-June-2015
    #blog: www.eskonr.com

    $CMObject = new-object -com "UIResource.UIResourceMgr"
    $cacheInfo = $CMObject.GetCacheInfo()
    $objects = $cacheinfo.GetCacheElements()  |
    where-object {$_.ContentId.Length -ne 8 -and  $_.ContentId -notlike 'conten*'} |
    select-object location, CacheElementID, ContentSize

    if ($objects.count -gt 1)
    {
    $objects |Format-Table -Wrap -AutoSize| tee-object -filepath "C:\windows\temp\cacheremoval.log"

    #Now calculate the total space freed
    $sum = $objects | Measure-Object -Sum -Property ContentSize
    $sum1=[math]::round($sum.sum/1024,2)
    "
    Freed Space  $sum1 MB" | Out-File "C:\windows\temp\cacheremoval.log" -Append
    #delete the software update folders from ccmcache folder

    ForEach ($Item in $objects)
    {
    $cacheInfo.DeleteCacheElement($item.CacheElementID)
    }
    }

    Download the script from TechNet Gallary here

    Thanks to my Friend Deepak in helping out the script commands Smile.

    cache size growing CacheInfoEx ccmcache cleanup ccmcache CM12 Configmgr 2012 configuration Manager Content How to clean ccmcache Powershell Remove ccmcache SCCM 2012 software update cleanup
    Share. Twitter LinkedIn Email Facebook Reddit

    Related Posts

    Export Microsoft Entra ID User Authentication Methods to CSV using PowerShell & Microsoft Graph API

    August 13, 2:08 pm

    SCCM SQL Report – Compare Installed Apps on TWO Different Computers

    July 13, 10:35 am

    Exporting Intune Win32 Apps with All Properties Using PowerShell and Microsoft Graph

    June 30, 7:01 pm

    11 Comments

    1. Sccm_buff on September 14, 2015 9:08 PM

      HI Eswar,

      Did you tried as legacy package is not working .

      Reply
      • Eswar Koneti on November 23, 2015 11:37 AM

        have you tried this using the DCM compliance rule ? it works great. try something like this using the script to remove only software update content
        Query for DCM Rule :

        #discover

        $UIResourceMgr = New-Object -ComObject UIResource.UIResourceMgr
        $Cache = $UIResourceMgr.GetCacheInfo()
        ($Cache.GetCacheElements() |
        where-object {$_.ContentId.Length -ne 8 -and $_.ContentId -notlike 'conten*'} |
        Measure-object).Count

        Remediation Script for Deletion:

        #remediate
        $UIResourceMgr = New-Object -ComObject UIResource.UIResourceMgr
        $Cache = $UIResourceMgr.GetCacheInfo()
        $Cache.GetCacheElements() |
        where-object {$_.ContentId.Length -ne 8 -and $_.ContentId -notlike 'conten*'} |
        foreach {
        $Cache.DeleteCacheElement($_.CacheElementID)
        }

        Reply
    2. Sudarsen on July 23, 2015 12:45 PM

      Hi Eswar,

      Great script just tested the same and it works brilliantly. Thanks for your wonderful work.

      Could you let me know how we can find out using script, content that are set to "Persist content in the client cache"

      Thankyou..

      Reply
      • Eswar Koneti on July 23, 2015 1:43 PM

        you can try something like this http://eskonr.com/2015/05/sccm-configmgr-2012-how-to-extract-information-from-xml-file-stored-in-sql-db-for-application-properties/ to get the properties of app that is configured with "Persist content in the client cache"

        Reply
        • BhaskarK on August 4, 2015 8:05 PM

          Hi,

          Thanks for sharing the script, it works well !!

          However unable to get this working as a SCCM package, set-ExecutionPolicy Unrestricted -force has been set on the PC so if I run it manually it works fine but not as a SCCM legacy package program.
          Program has been set to run with admin rights,SCCM program exits with code is 0 but it does not remove any folders from cache.
          have you seen this behavior before,I am facing the same issue with vb script based method too.

          Reply
          • Eswar Koneti on August 28, 2015 8:35 AM

            let me check on this and come back to you.

            Reply
            • Vilas on April 20, 2016 5:12 AM

              Happening to SCCM package that I created using your script. SCCM deployment shows success but does not delete any cache folders. Did you get chance to investigate this behavior?

              Reply
              • Eswar Koneti on May 28, 2016 12:48 AM

                Hi Vilas,
                Have you tried with Configuration Item/Baseline method ? it works good for me. I will look at software deployment method .

                Regards,
                Eswar

              • Vilas on June 27, 2016 8:58 PM

                I haven't tried it. I will try and let you know.

    3. kumar on June 5, 2015 8:58 AM

      script works great.thanks for your contribution

      Reply
    4. madhu on June 4, 2015 9:33 PM

      thank you

      Reply

    Leave a ReplyCancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Sign Up

    Get email notifications for new posts.

    Author

    I’m Eswar Koneti ,a tech enthusiast, security advocate, and your guide to Microsoft Intune and Modern Device Management. My goal? To turn complex tech into actionable insights for a streamlined management experience. Let’s navigate this journey together!

    Support

    Awards

    Archives

    © Copyright 2009-2025 Eswar Koneti, All rights reserved.

    Type above and press Enter to search. Press Esc to cancel.