Filter Out Unavailable Servers

by Oct 23, 2009

Even PowerShell v.1 has remarkable remoting capabilities–as long as you can make sure the target systems are online. Otherwise, you run into lengthy network timeouts. Here is a quick filter you can use to filter lists with IP addresses and computer names. Check-Online will only let those pass a pipeline that can be pinged successfully:

filter Check-Online {
trap { continue }

. {
$obj = New-Object system.Net.NetworkInformation.Ping
$result = $obj.Send($_, 1000)
if ($result.status -eq 'Success') { $_ }

Check out how this works:

"","noexists","" | Check-Online

Twitter This Tip! ReTweet this Tip!