Link to home
Start Free TrialLog in
Avatar of creative555
creative555

asked on

Script is needed to ping the servers by name and output the server names with their IPs into csv.

Hello,
I need a script that pings the servers by name using inputfile with servernames, and then outputs the server names with their IPs into csv.

Thank you very much!
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Try this

Test-Connection server1, server2, etc, | Out-File C:\PingResults.csv

Open in new window



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
[code]

$Computers = Get-Content C:\Computerlist.txt

Test-Connection $Computers | Out-File C:\pingresults.csv

Open in new window

Avatar of creative555
creative555

ASKER

Hi,
I was wondering if it is possible to produce a cleaner output - just one line - per server name.

Below is the output for one server listed 4 times. Also, could you please add the line for the servers that dont respond to be listed as well in the output as "down" or Not responding...etc

Thank you so much.

------      -----------      -----------      -----------      -----      --------
USWESWNE3I...      NYC-FNGFIPR01      10.42.30.16             32      98
USWESWNE3I...      NYC-FNGFIPR01      10.42.30.16             32      114
USWESWNE3I...      NYC-FNGFIPR01      10.42.30.16             32      105
USWESWNE3I...      NYC-FNGFIPR01      10.42.30.16             32      107
ASKER CERTIFIED SOLUTION
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much! Actually it exports one line per server. Excellent!