Last few weeks I’ve been implementing a MED-V solution at a customer.
Since this customer is using SCCM for deployment of their client OS and applications, they wanted me to deploy the MED-V solution by using SCCM. This went without any hickups, with one exception.
By default the SCCM Client cache is set to 5GB. My problem with this was that my MED-V image was about 17GB!
Since the size of the client cache can only be configured when you install the SCCM client on the device, and can not be changed by a simple registry value, I started scripting.
This is what I came up with… and found it extremely useful since I had to change the size of the client cache in the entire environment!
args = WScript.Arguments.Count
If args < 1 then
WScript.Echo "usage: sccmcache.vbs [New size in MB] "
WScript.Quit
end If
strComputer = "."
intCacheSize = WScript.Arguments.Item(0)
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/ccm/SoftMgmtAgent")
Set colItems = objWMIService.ExecQuery("Select * from CacheConfig")
For Each objItem in colItems
objItem.Size = intCacheSize
objItem.Put_ 0
wscript.echo "The SCCM cache size on " & UCase(strComputer) & " located at " & objItem.Location & " will be changed to: " & objItem.Size & " MB"
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service Where Name = ‘CCMExec’")
For Each objItem in colItems
objItem.StopService(strServiceName)
Wscript.Sleep 10000
objItem.StartService(strServiceName)
Next
wscript.echo "The SCCM cache size on " & UCase(strComputer) & " located at " & objItem.Location & " has been changed to: " & objItem.Size & " MB"
Hi, I have the same problem.
I have about 300 computers I would like to change the cache size on.
Trying to run this script, and I get an err 0x80041017 at line 17 char 1.
Trying to debug, but I’m not much of a scripter, so I doubt I’ll figure it out.
Hi Tracy,
I’ve just tested the script in my environment and it worked… so instead of troubleshooting you could go a step further and use PowerShell instead of the VBScript I provided.
John Grenfell wrote a PowerShell script to change the SCCM Client Cache size and published it in the Microsoft Script Library: http://gallery.technet.microsoft.com/scriptcenter/7a087f21-18a1-446a-a33c-38b187ea1716
or install the right click tools, they allow you to click a collection and run it on all clients assigned to that collection.
Hi
I did some modifications to your script since it didn’t work for me either.
Basically i changed the SELECT code for service restart, for me there where wrong ‘ surrounding the name and i changed the service name to correct specified service name that is returned.
The last row in the script is commented out since the variables in it is destroyed when the service restart is called and thus will not work without reinit the previous set variables.
Here is the script we are using.
args = WScript.Arguments.Count
If args < 1 then
WScript.Echo "usage: SCCMCacheSize.vbs [New size in MB] "
WScript.Quit
end If
strComputer = "."
intCacheSize = WScript.Arguments.Item(0)
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/ccm/SoftMgmtAgent")
Set colItems = objWMIService.ExecQuery("Select * from CacheConfig")
For Each objItem in colItems
objItem.Size = intCacheSize
objItem.Put_ 0
wscript.echo "The SCCM cache size on " & UCase(strComputer) & " located at " & objItem.Location & " will be changed to: " &
objItem.Size & " MB"
Next
Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootCIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Service Where Name= 'CcmExec'",,48)
For Each objItem in colItems
objItem.StopService(strServiceName)
Wscript.Sleep 10000
objItem.StartService(strServiceName)
Next
REM wscript.echo "The SCCM cache size on " & UCase(strComputer) & " located at " & objItem.Location & " has been changed to: " & objItem.Size & " MB"
Did some more changes to the script so even the last row will work.
Added Location and Size variables outside the “for each” loop that i filled with correct data for the last row, where i changed which variables it calls.
args = WScript.Arguments.Count
If args < 1 then
WScript.Echo "usage: CCMCacheSize.vbs [New size in MB] "
WScript.Quit
end If
strComputer = "."
intCacheSize = WScript.Arguments.Item(0)
Location = ""
Size = ""
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/ccm/SoftMgmtAgent")
Set colItems = objWMIService.ExecQuery("Select * from CacheConfig")
For Each objItem in colItems
objItem.Size = intCacheSize
objItem.Put_ 0
Location = objItem.Location
Size = objItem.Size
wscript.echo "The SCCM cache size on " & UCase(strComputer) & " located at " & objItem.Location & " will be changed to: " & objItem.Size & " MB"
Next
Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootCIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Service Where Name= 'CcmExec'",,48)
For Each objItem in colItems
objItem.StopService(strServiceName)
Wscript.Sleep 10000
objItem.StartService(strServiceName)
Next
wscript.echo "The SCCM cache size on " & UCase(strComputer) & " located at " & Location & " has been changed to: " & Size & " MB"