I have a text file containing a list of a few hundred server names
Server1
Server2
Server3
Server4
and so on...
I want to run a batch file which will take this file , ping all of them and return just the IP address if found, or "DOWN" if unreachable or not found. I want the output to go into output.txt, and the output only needs to be the IP address or "DOWN".
Sample output:
176.28.29.100
DOWN
176.28.29.105
176.28.29.110
Edit: I am new to batch and so far I have done this: Throw servernames into excel, get this in another column for the number of servernames
ping -n 1 servername | findstr "Pinging host" >> out.txt
...
The output I get is in the form
Ping request could not find host Server1. Please check the name and try again.
Pinging Sever2 [176.28.29.105] with 32 bytes of data:
Reply from 176.28.29.110: Destination host unreachable.
Want to get just the IPs
to process a file line by line, use
for /f
:(adapt the
echo
line to your needs)