Pretend some server admins were going to change out their IPs from their 208 addresses for some new IPs and you needed to test for connectivity for all the IPs involved; server and services. You may want to do something similar to the following...
## The Scripting Guys Test-Port script
## https://gallery.technet.microsoft.com/scriptcenter/97119ed6-6fb2-446d-98d8-32d823867131
## Pretend I got IBM Domino servers in cluster pairs like this...
app001/srv/mycompany 10.10.10.23
app011/srv/mycompany 10.10.10.24
app021/srv/mycompany 208.109.4.218 # godaddy.com is not my server.
app022/srv/mycompany 208.109.4.219 # I don't know who this is.
app002/srv/mycompany 10.10.2.54
app012/srv/mycompany 10.10.2.55
## From a cmd I can issue these commands and capture the results
ping 10.10.10.23
ping 10.10.10.24
ping 208.109.4.218
ping 208.109.4.219
ping 10.10.2.54
ping 10.10.2.55
tracert 10.10.10.23
tracert 10.10.10.24
tracert 208.109.4.218
tracert 208.109.4.219
tracert 10.10.2.54
tracert 10.10.2.55
## I Want to see the successful connection to the NRPC port
start telnet 10.10.10.23 1352
start telnet 10.10.10.24 1352
start telnet 208.109.4.218 1352
start telnet 208.109.4.219 1352
start telnet 10.10.2.54 1352
start telnet 10.10.2.55 1352
## Domino console batch saved as trace.txt and piped in to the console
trace 10.10.10.23
trace 10.10.10.24
trace 208.109.4.218
trace 208.109.4.219
trace 10.10.2.54
trace 10.10.2.55
## When your done with this you can search the log for messages like...
## Network: 10.10.10.23 is the server address of server CN=app001/OU=srv/O=mycompany
## I typically just search on " is the server address of server CN="
## Make sure to include the double quotes.
## Singular test
$tcpObject = New-Object System.Net.Sockets.TcpClient
$tcpConnect = $tcpObject.BeginConnect('10.10.10.23','1352',$null,$null)
$tcpConnect.AsyncWaitHandle.WaitOne(1000)
$tcpObject.Close()
## playing around
$Server = '10.10.10.23'
$Server = '10.10.10.24'
$Server = '208.109.4.218'
$Server = '208.109.4.219'
$Server = '10.10.2.54'
$Server = '10.10.2.55'
## Lets to a batch
$ServerList = @('10.10.10.23',
'10.10.10.24',
'208.109.4.218',
'208.109.4.219',
'10.10.2.54',
'10.10.2.55')
$port=1352
foreach($Server in $ServerList){
$tcpObject = New-Object System.Net.Sockets.TcpClient
$tcpConnect = $tcpObject.BeginConnect($Server,$port,$null,$null)
$wait = $tcpConnect.AsyncWaitHandle.WaitOne(1000)
($server+" "+$wait)
$wait=$null
$tcpObject.Close()
}
This batch audit at the end creates a result similar to ...
10.10.10.23 True
10.10.10.24 True
208.109.4.218 False
208.109.4.219 False
10.10.2.54 True
10.10.2.55 True