I haven’t posted anything new in a while, but I just wanted to draw attention to what I consider to be my Number One, Most Useful, Best Script on this site. Why am I bothering to do this? Because, as I analyze the traffic to this site, I see a lot of people are finding lots of other good stuff, but my best, most valuable and productive gem is not getting the exposure that it should.
Ready? Here goes…
The Number One, Most Useful, Most Productive Script I’ve Ever Posted to this Site (to date) IS:
Not to brag, but without question, the bgping.ps1 Background Bulk Ping script kicks major butt! Ok, I guess I am bragging just a little , but really 99% of the credit here goes to the PowerShell team for creating such a great command shell, rich with so many useful cmdlets and options.
This script came about due to an ongoing need that I have to ping thousands of hosts and get results back as quickly as possible. After searching high and low I could not find any utilities to adequately handle the job in a reasonable amount of time. The standard “ping” command certainly couldn’t do it and other utilities that I found were far too limited. So I set out to write my own high-performance bulk pinger.
When I first approached this task, I immediately recognized (the obvious) that multitasking was going to be needed to speed things up. So I began to write a GUI application in Vb.Net to handle the job. With quite a bit of effort I got something working but it became more and more buggy when I started pushing its limits to handle thousands of hosts. I was trying to keep the application as interactive as possible, updating a massive host matrix display with real-time ping results. This looked very cool but was becoming a challenge to keep stable. In particular, getting multiple threads to play well with the GUI was a major pain. I’m sure this is do-able but my VB approach was taking way too much time and I needed quicker results.
I did not even consider using PowerShell initially as I was unaware of the -AsJob switch used by many commands to submit background jobs. When I discovered the powerful combination of the test-connection cmdlet and the -AsJob option, I thought I’d give it a try. There were a couple of gotchas with the PowerShell approach, For example, when a single host ping fails within a job, the whole job fails and no results are returned. But I found ways to recover from this and without too much effort I got a reliable and lightning-fast utility up and running.
Now I can get ping results for literally thousands of hosts in record time. Example: 12,749 pings completed in 2 minutes, 27 seconds.
Here’s a screenshot:
I can’t imagine getting along without this script.
I hope more visitors find this to to be as useful as I do.
If you happened to somehow miss the gigantic link near the top of this post, you can click HERE to get to the BgPing bulk ping script.