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 file(.txt).

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

$Mylist = Get-Content D:\scripts\list.txt #this is where you put your list of computers
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 Computers :)"
$GoodArrayList
Write-Host -ForegroundColor Red "Bad Computers :("
$BadArrayList

 

2 thoughts on “How to Ping a List of Computers”

  1. I tried this script but it gave me the below error:

    At line:22 char:2
    + [/powershell]
    + ~
    Missing type name after ‘[‘.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingTypename

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.