Advertisement
easternnl

Ping-Host Example

May 13th, 2015
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Ping-Host {param (    [string ]$HostName,
  2.                                           [int32] $Requests = 1)
  3.    
  4.       for ($i = 1; $i -le $Requests; $i ++) {
  5.             $Result = Get-WmiObject -Class Win32_PingStatus -ComputerName . -Filter "Address=' $HostName'"
  6.             Start-Sleep -Seconds 1
  7.             if ($Result .StatusCode -ne 0) { return $FALSE }
  8.       }
  9.       return $TRUE
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement