Powershell to Ping Given Rage of IP Address and Get the Status

Below Powershell helps to ping given set of ip address and get the result status and also provides the status of number of machines which are rechable

$ping = New-Object System.Net.NetworkInformation.Ping
$i = 0
1..255 | foreach { $ip = “192.168.1.$_”
$Res = $ping.send($ip)
if ($Res.Status -eq “Success”)
{
$result = $ip + ” = Success”
Write-Host $result
$i++
}

$Hosts = [string]$i + ” Hosts is pingable”

Write-Host $Hosts

2 thoughts on “Powershell to Ping Given Rage of IP Address and Get the Status

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