# Check current CCMCache size $before = (Get-ChildItem "C:\Windows\ccmcache" -File -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object Length -Sum).Sum Write-Host ("CCMCache before cleanup: {0:N2} GB" -f ($before / 1GB)) # Clear CCMCache using ConfigMgr API $ccm = New-Object -ComObject UIResource.UIResourceMgr $cache = $ccm.GetCacheInfo() $cache.GetCacheElements() | ForEach-Object { $cache.DeleteCacheElement($_.CacheElementID) } # Check CCMCache size after cleanup $after = (Get-ChildItem "C:\Windows\ccmcache" -File -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object Length -Sum).Sum Write-Host ("CCMCache after cleanup : {0:N2} GB" -f ($after / 1GB)) Write-Host ("Space reclaimed : {0:N2} GB" -f (($before - $after) / 1GB)) # Check free space on C: $drive = Get-PSDrive C Write-Host ("Free space on C: {0:N2} GB" -f ($drive.Free / 1GB))