How to Ping a List of Computers

Many times It happens that we need to check if a list of computers is active, so how do you ping multiple computers at once?

Use this Powershell script to test connectivity to your list of computers. it will produce two lists of Bad (unresponsive) and Good(Responsive) computers.

You need to change “D:\scripts\list.txt” to the path where your saved your computers list.

Also, you can un-comment  #Write-Host $name… to view the list if computers with different colors

$Mylist = Get-Content D:\scripts\list.txt
Clear-Host
[System.Collections.ArrayList]$GoodArrayList = @()
[System.Collections.ArrayList]$BadArrayList = @()
 

foreach ($name in $Mylist){
  if (Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){
    #Write-Host $name -ForegroundColor Cyan
    $GoodArrayList.Add($name)
  }
 
else{
    #Write-Host $name "down" -ForegroundColor Red
    $BAdArrayList.Add($name)
  }
}
Write-Host -ForegroundColor Cyan "Good"
$GoodArrayList
Write-Host -ForegroundColor Red "BAd"
$BadArrayList

Leave a Reply