Simple Ping Test to List of Computers Using PowerShell

The following script can be used to perform a simple PING test to a list of computers using PowerShell.

Simply create the script (I call mine PingTest.ps1″) and in the same folder create a Computers.txt with a list of devices you want to ping. All of your core SCCM Site Systems is a good example.

Script:

$Computers = Get-Content "$PSScriptRoot\Computers.txt"

forEach ($comp in $Computers) {
   if (Test-Connection -ComputerName $comp -Count 1 -Quiet) {
      $comp | Out-File -FilePath $PSScriptRoot\ONLINE.txt -Append
      Write-Host "$comp`tONLINE" -ForegroundColor Green
   }
   else {
      $comp | Out-File -FilePath $PSScriptRoot\OFFLINE.txt -Append
      Write-Host "$comp`tOFFLINE" -ForegroundColor Red
   }
}

Leave a Comment