After coming across this several times, it has recently occurred to me that SCCM is missing what I would call a very important feature, The ability to manage the client cache size.
A reasonable person would assume that this option would be part of the client settings, however a quick look through will reveal that no administrative options exist.
There are many scripts out that that are designed to change the SCCM client cache size, these include “Program deployments” (Not really what you should be doing with SCCM now) and scripts that set the size and then write a registry value for detection. Both of these methods are far from what I would consider best practice and do not guarantee successful deployment or reporting, and also don’t take advantage of the full capabilities of SCCM
I have written two different scripts to accomplish this task. A PowerShell script, which is the preferred method, and a VB script, which is good for environments where PowerShell is not an option (such as sites with execution policy and signing restrictions)
PowerShell:
This script can be run with the argument DesiredCacheSizeMB, for example
SetSCCMCacheSize.ps1 -DesiredCacheSizeMB 10240
param($DesiredCacheSizeMB) $DesiredCacheSizeBytes = $DesiredCacheSizeMB * 1024 * 1024 $ClientCache = Get-WmiObject -namespace root\ccm\SoftMgmtAgent -class CacheConfig $CacheLocation = $ClientCache.Location $CacheDriveName = $CacheLocation.Substring(0,2) $CacheDrive = get-WmiObject win32_logicaldisk | Where {$_.DeviceID -eq $CacheDriveName} $FreeSpaceBytes = $CacheDrive.FreeSpace IF ($FreeSpaceBytes -gt $DesiredCacheSizeBytes) { $ClientCache.size = $DesiredCacheSizeMB $ClientCache.InUse = "True" $ClientCache.Put() Exit 3010 } ELSE { Exit 112 }
You may notice that is is collecting wmi disk information. THis is to validate that there is sufficient disk space to expand the cache. You should set free disk space as a requirement within the deployment type
For the detection method, use the following script but making sure you change the value to suite what you are aiming for
$ClientCache = Get-WmiObject -namespace root\ccm\SoftMgmtAgent -class CacheConfig $ClientCache.Size -eq "10240"
VBScript:
This is likely to work in more environments but Microsoft are starting to phase out vbscipt so this won’t work forever. I would also like to thank Nathan Grieve for helping me out with this one, it was a bit of a tricky one
Just like the PowerShell script, this will check for free disk space before attempting the change. This scipt has arguments but are put in without switched, for example
cscript.exe “SetSCCMCacheSize.vbs” 10240
On Error Resume Next Dim UIResManager Dim Cache Dim CacheSizeMB Dim CacheSizeBytes Dim CacheDrive Dim strComputer Dim Str strComputer="." CacheSizeMB=WScript.Arguments(0) CacheSizeKB=CacheSizeMB * 1024 * 1024 Set objWMIService1 = GetObject("winmgmts://" + strComputer + "/root/ccm/SoftMgmtAgent") Set colItems = objWMIService1.ExecQuery("Select * from CacheConfig") For Each objItem in colItems CacheDrive=(Left(objItem.Location,2)) Next Set objWMIService2 = GetObject("winmgmts:") Set objLogicalDisk = objWMIService2.Get("Win32_LogicalDisk.DeviceID=" + "'" + CacheDrive + "'") IF objLogicalDisk.FreeSpace > CacheSizeKB THEN Set UIResManager = createobject ("UIResource.UIResourceMgr") Set Cache=UIResManager.GetCacheInfo() Cache.TotalSize=CacheSizeMB WScript.Quit(3010) ELSE WScript.Quit(112) END IF
Detection method, remember to change the detection size
strComputer = "." Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/ccm/SoftMgmtAgent") Set colItems = objWMIService.ExecQuery("Select * from CacheConfig") For Each objItem in colItems IF objItem.Size = 10240 Then WScript.StdOut.Write "Installed" WScript.Quit(0) ELSE 'do nothing END IF Next</pre> <pre>
Both of these scripts will require a restart to take full effect so your SCCM deployment should reflect this