Powershell to ping Range of IP Address and gives status


posted by Krishna
12-29-2009

Downloads: 966
File size: 303 B
Views: 8,634

Embed
Powershell to ping Range of IP Address and gives status
  1. $ping = New-Object System.Net.NetworkInformation.Ping 
  2. $i =
  3. 1..255 | foreach { $ip = "192.168.1.$_"  
  4. $Res = $ping.send($ip
  5.  
  6. if ($Res.Status -eq "Success"
  7.  
  8. $result = $ip + " = Success" 
  9. Write-Host $result 
  10.  
  11. $i++ 
  12.  
  13.  
  14.  
  15. }  
  16. $Hosts = [string]$i + " Hosts is pingable" 
  17. Write-Host $Hosts 

Hi,

Powershell to ping range of IP addres and check if machine is reachable or not and gives the stauts of how many machines reachable in the specificed range

 

Regards,
Krishna
http://smtpport25.wordpress.com

Copyright 2012 PowerShell.com. All rights reserved.