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.
- Save the Script to C:\PowerShell\Get-PingStatus.ps1
- Launch PowerShell 2.0, and navigate to C:\PowerShell
- 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)
- Run the following Command from the PowerShell Prompt to show help information: get-help .\Get-PingStatusList.ps1 –detail
- 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:
- Upon completion, the output will appear similar to the following (hiding real computer names to protect the innocent):
- 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! firstname.lastname@example.org