Removing a package from the CCMCache

As part of troubleshooting I had a need to manually remove a package from the config manager cache (You shouldn’t be doing this!) aside form using the built in option to clear the whole cache the following PowerShell will do the job for you:


$CmObject= New-Object -ComObject “UIResource.UIResourcemgr”
$CacheObjects = $CmObject.getCacheInfo()
$toBeDeleted = $CacheObjects.GetCacheElements() | Where-Object contentid -like $PackageToDelete

If ($toBeDeleted){
$elementID = $toBeDeleted.cacheElementID
write-host “Package Deleted”
Else{ write-host “Package doesn’t exist”}

Leave a Reply

Your email address will not be published. Required fields are marked *