随笔 - 24, 文章 - 0, 评论 - 1, 引用 - 0
数据加载中……

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 -"address='$computer'"
   #$pingresult 
= gwmi -query "SELECT * FROM Win32_PingStatus WHERE Address = '$computer'"
   
if($pingresult.statuscode -eq 0) {$trueelse {$false}
}

Function Ping-Exe{
    $reply 
= Ping -1 -1000 $args;
    
Return $?;
}

Function Ping-Exe{
    (Ping 
-1 -1000 $args|out-string) –match “Reply”;

}

posted on 2009-04-10 13:59 nicktang 阅读(230) 评论(0)  编辑 收藏 引用 所属分类: Powershell

只有注册用户登录后才能发表评论。