Get-PingStatusList.ps1–Ping Hundreds of Systems Quickly Using the Start-Job Command in PowerShell

Here is a good example of the power of PowerShell 2.0. Say you have list of several systems, and you simply want to see if they respond to a ping. This script leverages PowerShell’s “Start-Job” cmdlet to launch multiple background jobs at one time, as opposed to the old-school sequential ping check. I have used this script to perform a ping check to thousands of systems in a matter of MINUTES! This Script requires PowerShell 2.0 and the .Net Framework 3.5. As configured, the script will run a maximum of 50 concurrent jobs, so it will ping the first 50 systems, and as each job completes, it will add more to the queue.

 

  1. Save the Script to C:\PowerShell\Get-PingStatus.ps1
  2. Launch PowerShell 2.0, and navigate to C:\PowerShell
  3. Create a text file that contains a list of all systems you want to ping, one system per line:(for our example, it’s C:\Temp\TestComputers.txt)
  4. Run the following Command from the PowerShell Prompt to show help information: get-help .\Get-PingStatusList.ps1 –detail
  5. You will see from the help that you can execute .\Get-PingStatusList.ps1 C:\temp\TestComputers.txt The output would appear similar to Example 2 in the integrated help:
  6. Upon completion, the output will appear similar to the following (hiding real computer names to protect the innocent):
  7. And finally, a gridview will display with the servername and a status code for each one. You can use this gridview to easily sort, filter, and copy the contents to a spreadsheet if desired.

Learn more about the start-job cmdlet.

Try it out, and send me your feedback! ramseyg@hotmail.com

Published Friday, January 07, 2011 11:25 PM by gramsey
Filed under:

Comments

No Comments
Powered by Community Server (Commercial Edition), by Telligent Systems