Increase MEMCM cache on client from CM console

Sometime it is nice to be able to run a script from CM directly against any given computer och collection without going through and deploying it first.

Fortunate, CM console contains a Script function for doing just that, we are going to use it to increase the CM client cache size on our clients.

It can be used to decrease the value too with some minor changes, but keep in mind if doing so you might need to empty the client cache first, not sure if CM client acknowledge the size reduction automatic and does a automatic clean or if the client cache gets screwed up.

Always test script on a single computer via Powershell ISE or another editor to make sure it work.

The script will get the current cache size on the client and will match it with the new size and if the new size is greater than the current it will set the new size on the client, but if the new size is lower than the old one or equal it will do nothing.

# Get current cache size
$cCache = Get-WmiObject -Namespace 'ROOT\CCM\SoftMgmtAgent' -Class CacheConfig | select -ExpandProperty Size

# New cache size
$nCache = 20480

# Check if client cache size is less than new value
if($cCache -lt $nCache){
    $Cache.Size = $nCache
    $Cache.Put()
    Restart-Service -Name CcmExec
}

# Get current cache size again
$cCache = Get-WmiObject -Namespace 'ROOT\CCM\SoftMgmtAgent' -Class CacheConfig | select -ExpandProperty Size

if($cCache -eq $nCache){
    return $true
}
else{
    return $false
}

Leave a Reply

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