A colleague of mine uses this handy tool (and now I do too!).  It’s called a “for loop“.  From a Windows command line you can run an executable with options against a list of PC’s (or any list for that matter).  The command will iterate through each item in your list.

Here’s the code and procedure:

PSTools lets you run remote commands on Windows PC’s download it and extract the files: Download

Make  a list of PC’s in your domain, M$’s got a nice method for enumerating computers in a Windows domain:  Link

To make it easy, put your text file with the list of domain computers in the same directory of your PSTools (I called mine “computers.txt”).  Open a command prompt and migrate to the PSTools directory.   If you type in “for /?” you get a HUGE list of methods for the “for” command line methodology.

You’ll see a line like this in the list which is what we’re using, I list the process running called “OUTLOOK”, this means those in the list are actively running OUTLOOK:

FOR /F [“options”] %variable IN (file-set) DO command [command-parameters]

Run this: for /f %i in (computers.txt) do pslist -e OUTLOOK %i

You’ll get something back that looks like this:
________________________________________________________

Process information for COMPUTER:

Name                    Pid      Pri Thd  Hnd   Priv        CPU Time    Elapsed Time
OUTLOOK            2520   8  40 2540 218408     0:01:23.750     8:10:55.620
________________________________________________________

Outlook takes a shade over 1 minute of my CPU time in the 9 hours my PC’s been up and running.  If you’ve got a rougue process taking over a machine somewhere on your network pslist.exe is a great way to inspect that machine and evaluate what’s running or how many resources something is utilizing.

You can browse the PSTools apps to see what hidden treasure you can find or download other exe’s that run on Windows!  Cygwin has a TON of exe’s that run on Windows, they can help you do all kinds of automated tasks on your machine or remote machines.  I know I haven’t even cracked the surface!