Check Online Status

by Mar 30, 2009

When managing more than just one system, you may want to remotely access those systems. Maybe you use WMI to do that. However, when you try and access a system that is offline, you probably run into a network timeout.

Here is a simple filter that checks whether an IP address or computer name can be pinged. Only then is the name handed on to the next pipeline element. This way, you can add the new filter anywhere in your pipelines where you must limit IP addresses or PC names to online systems.

Note that systems may still be online yet ignore ping requests due to security restrictions.

filter Check-Online {
trap { continue }

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

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