Quick one,

I have to keep testing connections to servers for various reasons, so i’ve put together this script (incredibly quick and easy) to get 2 output arrays one for computers i can connect to and one for computers i cant.

# Check if you can ping list of servers
$servers = get-content "C:\Temp\serverList.txt"
$pingable  = @()
$notpingable = @()

foreach ($s in $servers) {
    if (Test-Connection -ComputerName $s -Quiet -Count 1)
        {
            $pingable += $s
            write-host = "Connect     $s"
        } 
    else 
        {
            $notpingable += $s
            write-host = "Failed      $s"
        }
}
Advertisements