Script to ping multiple devices


Script to ping multiple devices

This Script can be used by admins to generate a ping response to any device in a one go. It can be used to check the connectivity to a number of devices post activity in a one go.


Prerequisite:-


1. Windows PowerShell

How To:-


1. Provide the devices name in a .csv file (file name devices.csv) and keep that file on system drive(C:)
2. csv file should have two columns dev and ipaddress. dev column should contain device hostnames and ipaddress column should have device ipadderss. 
3. Script is tested and safe to run.
4. Result will be saved on the C drive, if you need to save it somewhere else then please modify the last line of the script with the desired path
5. Out-put of the script will be saved in a .csv format.




Code:-

$report=@()
$Devs=import-csv "$env:homedrive\Device.csv"

foreach($dev in $devs){

$data=''|select Host, IP, Result, Response
$data.host=$dev.dev
$data.IP=$dev.ipaddress
$pngrslt=ping $dev.ipaddress
$data.result=$?
$data.response=$pngrslt | out-string

$report+=$data
}

$report|export-csv "$env:homedrive\ping_response.csv" 




Comments