Created
June 1, 2021 19:43
-
-
Save karoltheguy/a68ccff6905aaa0ae9483783fec84e03 to your computer and use it in GitHub Desktop.
Test connections on a list of ports from a list of remote hosts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$serverlist = "localhost", "127.0.0.1" #hosts to test FROM | |
$target = "google.ca" | |
$portlist = 8199, 8198, 8197 | |
Write-Host "Target: $target" | |
foreach ($s in $serverlist) { | |
Write-Host "--------------------------" | |
Invoke-Command -ComputerName $s -ScriptBlock { | |
foreach ($p in $Using:portlist) { | |
$connection = Test-NetConnection -ComputerName $Using:target -Port $p | |
Write-Host $Using:s on $p : $connection.TcpTestSucceeded | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment