Ping Function
生活随笔
收集整理的這篇文章主要介紹了
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”;
}
{
????$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”;
}
轉載于:https://blog.51cto.com/nicktang/148258
總結
以上是生活随笔為你收集整理的Ping Function的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 宝宝出生了
- 下一篇: 在51CTO安了家。。。。