First, put all of your server names into a text file with each server name on a separate line. Let's call it "servers.txt" and save it (as you going to ping server names so make sure name resolution is happening).
Next, open Command Prompt and navigate to the folder where you just created the file in which you listed the name of servers.
Now, enter the following line on the command prompt:
for /f "tokens=1" %a in (servers.txt) DO @ping -n 1 %a
This will attempt to ping every system in the list and return the result.
If you want to save the ping results, use this instead,
for /f "tokens=1" %a in (servers.txt) DO @ping -n 1 %a >> PingResults.txt
The above script only sends one ICMP packet to each server you list. Now, that’s probably good for just seeing if the server is accessible or not. You may want to increase the number of ICMP packets sent to each server. You can do that by changing the value after -n.
You can also modify the ping command at the end of the command above as needed with options pertaining to ping.
or Using PowerShell
Test-Connection server1, server2, etc, | Out-File C:\PingResults.csv
Or do it this way to get the list of servers
$Computers = Get-Content C:\Computerlist.txt
Test-Connection $Computers | Out-File C:\PingResults.csv
That's it.......... 🙂
2 Comments
Goodone, thank you so much
Just what I needed! Thank you!