CA Tuesday Tip: Remotely check if a port is available / listening

Discussion created by Mark_Hanson Employee on Aug 27, 2013
Windows Powershell can be used to quickly test if a port is reachable.

First an example against a non-listening port on a remote Linux host:
PS C:\Windows\System32\drivers\etc> $socket = New-Object System.Net.Sockets.TcpClient("","5280")
[color=#fd0505]New-Object : Exception calling ".ctor" with "2" argument(s): "No connection could be made because the target machine actively refused it"
At line:1 char:21
+ $socket = New-Object <<<<  System.Net.Sockets.TcpClient("","5280")
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Here is the same test against a listening/reachable port:
PS C:\Windows\System32\drivers\etc> $socket = New-Object System.Net.Sockets.TcpClient("","5280")
PS C:\Windows\System32\drivers\etc> echo $socket

Client              : System.Net.Sockets.Socket
Available           : 13
Connected           : True
ExclusiveAddressUse : False
ReceiveBufferSize   : 8192
SendBufferSize      : 8192
ReceiveTimeout      : 0
SendTimeout         : 0
LingerState         : System.Net.Sockets.LingerOption
NoDelay             : False
This also works well to test if the 11.3 agent is listening/reachable on port 7520 (default).