When I was at the MMS this year, I asked the Microsoft product team if the CCMCache is OK to clean up, because a lot of files is in the folder, and there is no built-in to do so.
This is a standard Configuration Item, pretty easy when you get into it.
Let say, we want to delete all content in C:\Windows\ccmcache if its 60 days or older.
Discovery script:
$MinDays = 60 $UIResourceMgr = New-Object -ComObject UIResource.UIResourceMgr $Cache = $UIResourceMgr.GetCacheInfo() ($Cache.GetCacheElements() | where-object {[datetime]$_.LastReferenceTime -lt (get-date).adddays(-$mindays)} | Measure-object).Count
Like this:
If i just test this on a machine. It gonna look like this
The result is the number of files that are older than 60 days.
Remediation script:
<# $MinDays = 60 $UIResourceMgr = New-Object -ComObject UIResource.UIResourceMgr $Cache = $UIResourceMgr.GetCacheInfo() $Cache.GetCacheElements() | where-object {[datetime]$_.LastReferenceTime -lt (get-date).adddays(-$mindays)} | foreach { $Cache.DeleteCacheElement($_.CacheElementID) }
Like this:
Compliance rule:
Deploy this to some machines that you want to clean up, And you are good to go.
/Pontus