Example of command:
for /f %G in ('type "C:\PsTools\computerlist.txt"') do psexec \\%G -s -c my_batch_file.bat
-s = run as local system
-c = copy file over and then execute
Explanation:
Essentially what this command does is sets a variable for the machine name, and for every line in the computerist.txt file, replaces that variable (%G) with the target IP or hostname you want to connect to.
1. Download PS Tools. Save and extract the zip to C:\, or wherever the file needs to be saved at.Remember to adjust the command accordingly.
http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
2. Create a .bat file of what commands you want run. In this KB, we’re restarting the AMP service, then forcing and inventory. Save this .bat file in the C:\Pstools directory.
my_batch_file.bat:
cd C:\Program Files (x86)\quest\kace
AMPTools.exe restart
runkbot.exe 4 0
Note: If the agent is 7.2 or older the folder is: C:\Program Files (x86)\dell\kace
Agents with version 8.0 and above are located under C:\Program Files (x86)\quest\kace
3. Create a txt file called computerlist.txt and save it also in the C:\PSTools folder. It should look something like this:
computerlist.txt:
machine1
machine2
machine3
or
10.1.1.3
10.2.2.5
etc
If you need help, say getting a list of machines that haven’t inventory in the last day, you can run this from the reporting section of your K1 to get a list of IP’s:
select
IP
from
MACHINE
where
LAST_SYNC < DATE_SUB(NOW(), Interval 2 DAY)
4. Run the psexec command
for /f %G in ('type "C:\PsTools\computerlist.txt"') do psexec \\%G -s -c my_batch_file.bat
You should see psexec connect to each machine, one at at time, and run the commands in your .bat file. I tested this on windows 7 x64 machines, so if you have other architectures, you will need to adjust the .bat file accordingly.
© ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center