Ping Multiple Clients with Powershell
I am sure there are a 100 of these posts out there but my angle on this as always comes from a System Center Perspective!
Patch Compliance and acheiveing the holy grail of +98% compliance can be a difficult task so you need all the tools in your armoury and this tool can often be invaluable to save trying to connect to each machine manually.
When I am down to my last bunch of non-compliant machines, I am first looking for ones online to determine why they are not compliant.
From a ConfigMgr report, export the list and get these into a simple .txt format list and save the file.
With you below powershell script (which can be adapted for location of file) you can quickly see what clients are online for you to continue your troubleshooting exercise.
Below is an example:
Folder Created – C:\PowershellPing
File Created – C:\PowershellPing\Systems.txt (Contains List of Systems)
Create and save the following script as a .ps1 file
**Code Start***
$ServerName = Get-Content “C:\PowershellPing\Systems.txt”
foreach ($Server in $ServerName) {
if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {
“$Server Host is Up ”
} else
{“$Server Host Not Reachable”
}
}
***Code End***
From a powershell Window execute the following command:
*Note – This is my example file locations depend on what you setup
cd to the directory.
.\PingSystems.ps1 | Out-File -FilePath C:\PowershellPing\PingResults.txt -append
This will output a file like below: