PowerShell Ping Function

You can use the following boolean function to ping a host using powershell:

function Ping-Host {param( [string]$HostName,
[int32]$Requests = 3)

for ($i = 1; $i -le $Requests; $i++) {
$Result = Get-WmiObject -Class Win32_PingStatus -ComputerName . -Filter "Address='$HostName'"
Start-Sleep -Seconds 1
if ($Result.StatusCode -ne 0) {return $FALSE}
return $TRUE

Popular posts from this blog

IIS Client Certificate Revocation Check Disable

Configuring a Certificate on Exchange Receive Connector

How to Configure Message Forwarding on a Mailbox Level