Home / Articles / Scripts / Script to Ping a list of IPs

Script to Ping a list of IPs

There are times when you need to ping a list of IPs to determine which ones are up and which ones are down.  Below is a powershell script that will do just that:

#Below is a script used to identify if hosts are up or down
# The following line read a plain list of IPs from files.
$listofIPs = Get-Content “C:Documents and SettingsdnoyDesktopIPList.txt”
#create a blank array for the resolved names
$ResultList = @()
#resolve each of these addresses
foreach ($ip in $listofIPs)
{
$result = $null
$currentEAP = $ErrorActionPreference
$ErrorActionPreference = “silentlycontinue”
$ErrorActionPreference = $currentEAP
if (test-Connection -ComputerName $ip -Count 2 -Quiet )
{

$Resultlist += “$IP is UP”

}
Else
{
$Resultlist += “$IP is DOWN”
}
}
#Output to file
$resultlist | Out-File “C:Documents and SettingsdnoyDesktopIPList_Output.txt”

 

Please let Denver IT Services NOYNIM know if you need any other scripts.

 

 

Share


Comment on Script to Ping a list of IPs

Leave a Reply






Contact Us