[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 939
  • Last Modified:

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?
0
ntr2def
Asked:
ntr2def
  • 8
  • 5
1 Solution
 
ntr2defAuthor Commented:
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.
0
 
merowingerCommented:
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?!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ntr2defAuthor Commented:
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.
0
 
merowingerCommented:
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
0
 
ntr2defAuthor Commented:
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.
0
 
merowingerCommented:
huh? So SCCM will never work or?
0
 
ntr2defAuthor Commented:
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.
0
 
merowingerCommented:
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
0
 
merowingerCommented:
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

0
 
merowingerCommented:
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
0
 
ntr2defAuthor Commented:
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
0
 
merowingerCommented:
yeah sure. don't know what i thaught at this moment :)
strLocation = "D:\SCCM_Cache"

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.Location = strLocation
		objItem.Put_ 0
	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

0

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now