Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

SOLVED how to clean SCCM ccmcache folder

Status
Not open for further replies.

Rajni Kanyal

Member
Messages
20
Reaction score
0
Points
1
CCMCACHE is full for almost all the client in my company, and not getting deleted automatically, hence the new deployments are not running on the systems. Please suggest how can we delete the old files in ccmcache and make space for new deployments.
 
It is already set to 15 GB in our environment. Need to maintain that size. If you could help me clearing the old flders in ccmcache, it will be very useful to me.
 
This VB script should clear the ccmcache folder. Deploy the VB script to the clients using SCCM.

Code:
' Script to Clear SMS cache files
on error resume next
dim oUIResManager
dim oCache
dim oCacheElement
dim oCacheElements
set oUIResManager = createobject("UIResource.UIResourceMgr")
if oUIResManager is nothing then
'      wscript.echo "Couldn't create Resource Manager - quitting"
     wscript.quit
end if
set oCache=oUIResManager.GetCacheInfo()
if oCache is nothing then
     set oUIResManager=nothing
'      wscript.echo "Couldn't get cache info - quitting"
     wscript.quit
end if
set oCacheElements=oCache.GetCacheElements
'wscript.echo "There are " & oCacheElements.Count & " cache elements"
'wscript.echo
' ***** Begin CLEAR CACHE *****
for each oCacheElement in oCacheElements
oCache.DeleteCacheElement(oCacheElement.CacheElementID)
next
' ***** End CLEAR CACHE *****
' ***** Clean up *****
set oCacheElements=nothing
set oUIResManager=nothing
set oCache=nothing
 
You can check this script also, can automatically delete Ccmcach folder contents.

#Connect to Resource Manager COM Object

$resman

=new-object-com"UIResource.UIResourceMgr"

$cacheInfo

=$resman.GetCacheInfo()

#Enum Cache elements, compare date, and delete older than 60 days

$cacheinfo

.GetCacheElements() |

foreach

{$cacheInfo.DeleteCacheElement($_.CacheElementID)}
 
Status
Not open for further replies.
Back
Top