PoshCode Archive  Artifact Content

Artifact 5b290b3690e297b04627f51929f7a7ab9622788f118bcd2b6e52974270fc6990:

  • File ping-check-using-dotNet.ps1 — part of check-in [7a27ea1124] at 2018-06-10 12:57:04 on branch trunk — 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. (user: unknown size: 754)

# 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
}