Thursday, November 19, 2015
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 don't have sufficient space on SCCMCache.
Here's a script powershell to clean SCCM Cache , delete All subfolders that are note used since 30 day's
$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:\Install\Msi\Logs\cacheremoval.log "Clean CccmCache"
foreach ( $item in $objects )
{
$diffDate = $StartDate - $item.LastReferenceTime
if ( $diffDate.Days -gt $lastUsed )
{
$i++
remove-item -path $item.location
}
}
Labels:
SCCM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.