Auto Clean SccmCache with powerShell
If you deploy Application on your windows 10 using SCCM 2012 generates status ùessage ID 10050 it means that you dont have sufficient space on SCCMCache.
Heres a script powershell to clean SCCM Cache , delete All subfolders that are note used since 30 days
$CMObject = new-object -com "UIResource.UIResourceMgr"
$cacheInfo = $CMObject.GetCacheInfo()
$lastUsed = 30
$objects = $cacheinfo.GetCacheElements() | select-object location , LastReferenceTime, ContentSize
$StartDate=(GET-DATE)
$i=0
out-file -append -filepath C:InstallMsiLogscacheremoval.log "Clean CccmCache"
foreach ( $item in $objects )
{
$diffDate = $StartDate - $item.LastReferenceTime
if ( $diffDate.Days -gt $lastUsed )
{
$i++
remove-item -path $item.location
}
}
alternative link download