Skip to content
10/11/2008 / dimarzionist

howto: Ping remote host using PowerShell script

If you want to check availablity of some remote host in your powershell script you can use next simple piece of code to do exactly this:$MachineName = “mo-laptop”

$PingStatus = Gwmi Win32_PingStatus -Filter “Address =’$MachineName'” | Select-Object StatusCode

if($PingStatus.StatusCode -eq 0)

{

echo $MachineName

echo “Ping Success”

}

else

{

echo $MachineName

echo “Ping Failed”

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: