Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #########################################################
- # #
- # This script will do the following; #
- # - Read in a list of IP addresses #
- # - Strip off any port numbers #
- # - Remove duplicate IP addresses #
- # - Test the connection to each IP #
- # - Report the connection speed to each one #
- # #
- #########################################################
- # Prepare the results file
- "IP Address, response time" | out-file -FilePath "c:\temp\results.csv" -encoding utf8
- # Create the array for holding the list of addresses.
- $LIST = new-object system.collections.arraylist
- # Read in the list of addresses
- foreach ($line in get-content c:\temp\addresses.txt) {$LIST.add("$line")}
- # Remove any port suffixes
- $count=0;while ($count -lt $LIST.count){$LIST[$count]=$LIST[$count].split(":")[0];$count++}
- # Remove duplicates
- $count=0
- while ($count -lt $LIST.count)
- {
- if ($list[$count] -eq $list[$count+1])
- {
- $list.removeat($count+1)
- $count++
- }
- else
- {
- $count++
- }
- }
- # Test each IP
- foreach ($line in $LIST)
- {
- $test=test-connection -count 1 -quiet $line
- if ($test -eq $False)
- {
- write-host -foregroundcolor yellow $line,Failed
- "$line`tFailed" | out-file -append -filepath "c:\temp\results.csv" -encoding utf8
- }
- else
- {
- $test=test-connection -count 1 $line
- $responsetime=$test.responsetime
- write-host $line, $responsetime
- write-output "$line`t$responsetime" | out-file -append -filepath "c:\temp\results.csv" -encoding utf8
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement