In the final part of our mini-series, we add pipeline awareness to our super-fast Test-OnlineFast function. You now can pipe computer names into the function like this:

 
PS> 1..200 | ForEach-Object { "192.168.189.$_" } | Test-OnlineFast

Address         Online DNSName                            Status           
-------         ------ -------                            ------           
192.168.189.200   True DESKTOP-7AAMJLF.fritz.box          Success          
192.168.189.1     True fritz.box                          Success          
192.168.189.65    True mbecker-netbook.fritz.box          Success          
192.168.189.29    True fritz.repeater                     Success          
192.168.189.64    True android-6868316cec604d25.fritz.box Success          
192.168.189.112   True Galaxy-S8.fritz.box                Success          
192.168.189.142   True Galaxy-S8.fritz.box                Success          
192.168.189.129   True iPhonevMuzaffer.fritz.box          Success          
192.168.189.10   False                                    Request Timed Out
192.168.189.100  False                                    Request Timed Out 
(...)
 

Of course, you can still use the function with plain parameters as well:

 
PS> Test-OnlineFast -ComputerName google.de, microsoft.com, 127.0.0.1

Address      Online DNSName         Status           
-------      ------ -------         ------           
127.0.0.1      True DESKTOP-7AAMJLF Success          
google.de      True google.de       Success          
microsoft.com  False                Request Timed Out
 

And you can even use results from other cmdlets, provided you select the property you want to pass on to the function. The line below pings all computers in your Active Directory (you better limit this a bit or else might run out of resources):

 
PS> Get-ADComputer -Filter * | Select-Object -ExpandProperty DnsHostName | Test-OnlineFast 
 

Are you an experienced professional PowerShell user? Then learning from default course work isn’t your thing. Consider learning the tricks of the trade from one another! Meet the most creative and sophisticated fellow PowerShellers, along with Microsoft PowerShell team members and PowerShell inventor Jeffrey Snover. Attend this years’ PowerShell Conference EU, taking place April 17-20 in Hanover, Germany, for the leading edge. 35 international top speakers, 80 sessions, and security workshops are waiting for you, including two exciting evening events. The conference is limited to 300 delegates. More details at www.psconf.eu.

Twitter This Tip! ReTweet this Tip!

Anonymous