Ping Function

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”;

}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章