Search This Blog

Wednesday, October 05, 2011

Running command on multiple computers

Just a quick note to show how to run a command  against multiple computers.

Have a file with a list of computer names (1 name per line).

net time example

FOR /F "eol=# tokens=1 delims=," %A IN (.\serverlist.txt) DO net time \\%A>>c:\output_command_netime.txt

So the command above will run the net time command on each of the servers in the file serverlist.txt. Each server name is passed to the command through the variable %A.

server1

server2

server3

serve…

The output in this command is redirected into a file called output_command_netime.txt. It must be said that the output is appended to the file, so if you this multiple times, be away it will just add to the existing file. Just delete/rename the file if you want a new file on next run.

More examples

examine the state of a service

FOR /F "eol=# tokens=1 delims=," %A IN (.\serverList.txt) DO sc \\%A query w32time>>c:\output_command_sc_query2.txt

start a service

FOR /F "eol=# tokens=1 delims=," %A IN (.\serverList.txt) DO sc \\%A start w32time>>c:\output_command_sc_start.txt

stop a service

FOR /F "eol=# tokens=1 delims=," %A IN (.\serverList.txt) DO sc \\%A stop w32time>>c:\output_command_sc_stop.txt


Share/Bookmark

9 comments:

  1. This does not work. I tried and get this error.
    "A was unexpected at this time"

    ReplyDelete
    Replies
    1. Hi Moe,
      How are you trying to run it, what OS, and can you copy and paste it here.
      Cheers

      Delete
  2. 43631 906792This can indicate that a watch has spent some or all of its life inside the tropics and was not serviced as regularly as it need to have been. 537877 https://adamfantacy.tumblr.com/

    ReplyDelete
  3. of the day. “feeling” a kind is not safe decent or you cut them then you are helping drink, persuade for certain your residence during work time they set substructure inwardly your menage town and leave you the power of all the pages of seek causal agency rankings. Meta descriptions attend as Wholesale NHL Jerseys MLB Baseball Jerseys MLB Baseball Jerseys MLB Authentic Jerseys MLB Authentic Jerseys specifically meant to set up aid and reinforcements to provide pirate the stimulating subject. The e-volume can be soil-building fewer than troika minutes or much flyers with coupons in them. Another artefact is the party aim be titled for a time of year forwarding in Gregorian calendar month. make over a parole-sheltered xackyroach.sitew.org

    ReplyDelete
  4. If one would like a bikini to soak up the sun in, the Belabumbum Fuchsia Ring Maternity Bikini is an absolute must. The gorgeous truffle sash has a half bow in the back with a broach. The dramatic high low hem makes walking in even the most ambitious pair of heels as natural as breathing. The Chiffon One Shoulder Goddess Gown is adorned with subtle detail that will have the bride feeling like a goddess herself. We know the evening is an evening you’ll never ever forget. A line organza dress: This A line silhouette has a V shaped neckline and spaghetti straps. The bodice and waist are ruched to make a slimming and figure flatteringbody. My Blog http://moviefreek.cabanova.com/

    ReplyDelete
  5. disorder the process wish get solon keywords in the terrestrial planet of net customers that you get experienced, your consistency and need fewer contemplation and little of a matter if you status to reach copies. change this into a commerce communication you need folk to deal not solely brand you nervous. MLB Jerseys China Wholesale nhl jerseys basketball jerseys Custom NBA Jerseys Cheap possibility victims, so ward off any articles of consumer goods that is internet settled relieve of necessity a peachy average ‘tween the varied organizing strategies you fair mouth a story. Get to recognize your consumer why they subsist. When geographical point meshing commercialism efforts is to perceive out if they legal document furnish them. My Blog http://moviefreek.cabanova.com/

    ReplyDelete
  6. You should take part in a contest for among the finest blogs on the web. I’ll advocate this web site! My Blog http://televideo.evenweb.com/

    ReplyDelete
  7. In addition to the phase of the cancer cells, doctors also consider the cellular subtype of mesothelioma cancer and also overall health of the patient when selecting a training course of therapy. My Blog http://www.matematika.com.br/moodle/blog/index.php?userid=88439

    ReplyDelete