Function Ping-Net
{
$timeout=1000;#毫秒
trap { continue; }
$ping = new-object System.Net.NetworkInformation.Ping
$reply = new-object System.Net.NetworkInformation.PingReply
$reply = $ping.Send($args, $timeout);
if( $reply.Status -eq "Success" )
{
return $true;
}
return $false;
}
function Ping-Wmi {
Param([string]$computer)
$pingresult = Get-WmiObject win32_pingstatus -f "address='$computer'"
#$pingresult = gwmi -query "SELECT * FROM Win32_PingStatus WHERE Address = '$computer'"
if($pingresult.statuscode -eq 0) {$true} else {$false}
}
Function Ping-Exe{
$reply = Ping -n 1 -w 1000 $args;
Return $?;
}
Function Ping-Exe{
(Ping -n 1 -w 1000 $args|out-string) –match “Reply”;
}