Test-Connection to Multiple Hosts


posted by Talsu
06-27-2010

Downloads: 374
File size: 462 B
Views: 1,981

Embed
Test-Connection to Multiple Hosts
  1. Function Test-MultipleConnections 
  2.     param
  3.         [string]$Gateway,  
  4.         [int]$StartPosition = 1,  
  5.         [int]$EndPosition = 255 
  6.         
  7.  
  8.     if ($Gateway -match "(\d{1,3}\.){2}\d{1,3}"
  9.     
  10.         $StartPosition..$EndPosition |  
  11.         Foreach-Object
  12.             $ResultHash = @{} 
  13.             $ResultHash.Address = "{0}.{1}" -f $Matches[0], $_         
  14.             $ResultHash.IsSuccess = Test-Connection $ResultHash.Address -count 1 -quiet 
  15.              
  16.             New-Object PSObject -Property $ResultHash 
  17.         
  18.     

Test-Connection to many hosts.

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.