01 April, 2009

See which machine is alive...

If you need to run on a list of machines with some command, you want to make sure that the workstations (or servers) are alive and pingble.
The following script allow you to do just that.
It contains 3 elements:
  1. "computers.txt" - the full list of computers in your LAN (probably from AD), names only!!!
  2. "Step1.cmd" - run's the next file in a loop on each line from "computers.txt"
  3. "Step2.cmd" - The command itself.

content of step1.cmd:
======================
for /f %%A in (computers.txt) do (step2.cmd %%A)
======================

content of step2.cmd:
======================
ping -n 1 -w 300 %1 find "TTL">nul
IF %ERRORLEVEL% == 0 (echo %1 >> alive.txt) ELSE (echo %1 >> dead.txt)
======================

Put them all in the same directory, execute step1.cmd and the script will split the big list into 2 small lists, alive.txt and dead.txt - the content is self applies...

By for now...

No comments:

Post a Comment