Ping a host address by using Powershell

#create a ping object

$ping=New-Object net.NetworkInformation.Ping

#we gonna ping 4 times.

for ($i=0;$i -lt 4;$i++)
{
$result=$ping.send("www.google.com")
#if clause will decide whether it is ok or not.

if ($result.status -eq "Success")
{
$result.Address.ToString() + " IP address has been responding."
$result.Status
}
else{
"Failed"
}
}