PowerShell: Ping-Subnet
A couple a weeks ago I was hanging out in the PowerScripting Ustream waiting for the show to start. There were several of us caring on, when the interview subject Brandon Shell placed a call to scripting. He asked for a script to ping a subnet. There are many select-alive/ping-host scripts why write another one? The answer is simple pinging a target is easy, what Brandon was asking for was a fast way to generate the list of hosts. (Additionally, if you work with Active Directory then you can already see the usefulness in being able to ingest the subnets in sites and services as a parameter.) Shortly after Brandon made the request I opened my big mouth, and commented that the math was easy. The hard part is “threading”, as you know we can’t thread in PowerShell… but there are ways to perform concurrent operations. The PSJobs in V2 were purpose built for such a task. Unfortunately the *-job cmdlets use winrm as a backend, and require WS-MGMT to be installed/configured. As I was carrying on with this line of thought Brandon broke in, and informed me that the Get-WMIObject cmdlet in CTP3/V2 uses its own ‘backend’! He went on to inform me that all I needed was to tack on the –AsJob parameter… After a couple quick tests, I had a draft, and shortly thereafter a script!