# encoding: utf-8
# api: powershell
# title: ping check using dotNet
# description: ping check using dotNet ping. pieced together from existing examples on the web. Had to use $erroractionpreference = “SilentlyContinue” to make it work on non-existing systems.
# version: 0.1
# type: function
# license: CC0
# function: check-ping
# x-poshcode-id: 1418
# x-derived-from-id: 1419
# x-archived: 2009-10-26T15:26:01
#
#
function check-ping {
$erroractionpreference = "SilentlyContinue"
$ping = new-object System.Net.NetworkInformation.Ping
$rslt = $ping.send($args)
if ($rslt.status.tostring() eq Success) {
write-host $args + ping worked
}
else {
write-host $args + ping failed
}
$ping = $null
}