Powershell – Ping List of IPs

$names = Get-Content “C:\Temp\ips.txt”
foreach ($name in $names){
if (Test-Connection -Delay 15 -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){
$Output+= “$name,up”
Write-Host “$Name,up” -ForegroundColor Green
}
else{
$Output+= “$name,down”
Write-Host “$Name,down” -ForegroundColor Red
}
}
$Output | Out-file “C:\Temp\ipresult.csv”

Leave a Reply

Your email address will not be published. Required fields are marked *