Check and Fix SCCM Cache Size

I’ve run into issues where an SCCM client will get repaired and the cache size automatically goes back to 5120MB.  This causes a problem if you have applications that you are advertising that are bigger than 5GB.

So my solution was to created a PowerShell script that first checks to see what the current cache size is and if it is not what I specified change it and restart the SCCM Client on the host.  If the client is set to the cache size I have specified then simply exit.  I have also set this PS Script to be a scheduled task so it frequently runs the check.  You can do this very easily through Group Policy (if desired).

If you have any questions about this script, please feel free to contact me.


# Script developed by Harry Caskey
# harrycaskey@gmail.com
# http://www.harrycaskey.com/
# Please give me feedback on this script if it works for you!
#

# First thing is specify the WMI object you want to query.
$CacheSize = 51200
$Cache = Get-WmiObject -namespace root\ccm\SoftMgmtAgent -class CacheConfig
# Then run this IF statement to check to see if the Cache Size does not equal (-ne) to the $CacheSize variable .
If ($Cache.size -ne $CacheSize) {
$Cache.size = $CacheSize
$Cache.InUse = "True"
# If the cache size does not equal to the $CacheSize variable then apply.
$Cache.Put()
# Restarts the service after the Put() command. This is optional, not required and not recommended if you are deploying this script with SCCM.
#Restart-Service ccmexec
Exit
}
Else {
Exit
}

Here goes the script if you would like to download it: Set-SCCMCacheSize.zip

 

– Harry Caskey

3 Replies to “Check and Fix SCCM Cache Size”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.