Monday, August 15, 2016

Auto Clean SccmCache with powerShell

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 oSCCMCache.

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
       
    }

 }

Get

download
alternative link download

renata

About renata

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :