Link to home
Start Free TrialLog in
Avatar of ntr2def
ntr2def

asked on

script to change client cache location using pcs from a csv

I'm trying to see if anyone knows of a script that i can run remotely to change the cache path location on a remote client but importing a list of workstations. I can use client center to do one machine at a time but i would rather say import list then change path to c:\software. any ideas?
Avatar of merowinger
merowinger
Flag of Germany image

Avatar of ntr2def
ntr2def

ASKER

thats good info but im asking for help so if you can give me something in a form that shows an import of a csv or txt file encompassing together with changing the path of the sms cache location would be most helpful.
The script is not based on WMI so it cannot be executed from Remote.
Why do you want to execute the script remotely if you have SCCM to deploy the script to each client?!
Avatar of ntr2def

ASKER

we have software in place that blocks scripts like psexec from being run and software installation from being run from a network resource. It can only be run from a certain directory unfortunately when the client was installed it had its default settings. now in our current environment i need change the temp prgram directory to that "safe" directory. But since psexec isnt allowed to be run and also in using SCCM Client Center i can do one machine at a time, so I believe its using a WMI script and I want somthing that will allow a list import from a csv or txt file.
When using SCCM you can make sure a vbScript get's executed from the local computer e.g. C:\windows\system32\ccm\cache.
Also you could start a copy job into the "secure directory" and then start the script
Avatar of ntr2def

ASKER

i know I can do a copy but the problem is since the ccm\cache is not the "secure directory" the copy will be blocked.
huh? So SCCM will never work or?
Avatar of ntr2def

ASKER

so we have a test envrionment taht replicates our prod environment. If I use SCCM Client Center and say type in testMachine02 it will connect I will then click "Agent Actions">Select Cache Path. In the Cache Path I can type the path and save. Ok not a big deal  but trying to this for say 200 machines is not something I want to take the time to do. I'm hoping There is a script taht will enumerate what the SCCM Client Center is doing but instead of doing one machine I can feed a list of machines.
ok, your right. Roger Zander has included that in Client Center. So it should be possible via WMI...and it is.
I again did some research and found the WMI Class root/ccm/SoftMgmtAgent

Look here
http://myitforum.com/cs2/blogs/dhite/archive/2007/03/24/vbs-script-to-change-a-remote-sms-clients-cache-size.aspx
I've changed the Script so that it will loop throught all Clients which are defined within a textfile and change the Cache then....
intCacheSize = "5000"

Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFile = objFSO.OpenTextFile("C:\ComputerList.txt")
 

Do While Not objFile.AtEndOfStream 
 	
 	strCurrentPC = objFile.ReadLine 
 	
	Set objWMIService = GetObject("winmgmts://" & strCurrentPC & "/root/ccm/SoftMgmtAgent")
	Set colItems = objWMIService.ExecQuery("Select * from CacheConfig")
	 
	For Each objItem in colItems
		objItem.Size = intCacheSize
		objItem.Put_ 0
		Wscript.Echo "The Cache On " & UCase(strCurrentPC) & " Located At: " & objItem.Location & " Will Be Changed To: " & objItem.Size & " MB"
	Next
	 
	 
	Set objWMIService = GetObject("winmgmts:\\" & strCurrentPC & "\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 "Done"

Loop

Open in new window

AddOn: Did not try it - So please give Feedback if there are some Errors.
AddOn2: If a Client is not reachable (off, firewall,...) the script will fail so you should build in some Error handling and maybe log fhe results into a file
Avatar of ntr2def

ASKER

just to clarify im working the actualy client cache location not the cache size does this script result in that? from skimming through it, it looks like its only affecting the client cache size
ASKER CERTIFIED SOLUTION
Avatar of merowinger
merowinger
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial