VBS Script To Change A Remote SMS Clients Cache Size

 

This VBS script will take a local or remote machine name from an input box and then will prompt you to enter a Cache size in MB that you want to change the Cache size to. The script will then stop and then start the SMS Agent Host by Name (CCMExec) to apply the change without the need to restart the service manually as is required when modifying the cache.

 

For more information see my post entitled: The SMS Advanced Client Temporary Program Download Folder Cache here:

 

http://myitforum.com/cs2/blogs/dhite/archive/2007/03/24/the-sms-advanced-client-temporary-program-download-folder-cache.aspx

 

Note: The Put method (Put_) is designed to be used when you either create or update a WMI instance or a class object and writes the changes to the specified WMI repository.

 

VBS Script:

 

strComputer = InputBox ("Enter Machine Name")

intCacheSize = InputBox ("Enter New Cache Size (MB)")

 

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

 

MsgBox "The Cache 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

 

MsgBox "Done"

 

Published Saturday, March 24, 2007 10:40 AM by dhite
Filed under:

Comments

No Comments