Test-TCPConnection

Help page for Test-TCPConnection

NAME
Test-TCPConnection

SYNOPSIS
Test a TCP Connection.

SYNTAX
Test-TCPConnection [-ComputerName] <String> -Port <Int32> [-Timeout <Int32>] [<CommonParameters>]

Test-TCPConnection [-ComputerName] <String> -Service <String> [-Timeout <Int32>] [<CommonParameters>]

DESCRIPTION
This CMDLET will connect to a remote host on a given port or a predefined service port and return a succes or failure.

PARAMETERS
-ComputerName <String>
provide a valid hostname of the remote host.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false

-Port <Int32>
Provide a TCP port number in the range of 1 – 65535

Required? true
Position? named
Default value 0
Accept pipeline input? false
Accept wildcard characters? false

-Service <String>
Provide a well know Service port to connect to, Valid options are:

SSH
SMTP
DNS
http
https
SMB
RDP
WINRM
WINRMSSL

Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Timeout <Int32>
Timeout in Milliseconds. Default is 80 milliseconds

Required? false
Position? named
Default value 80
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Examples

————————– EXAMPLE 1 ————————–

PS C:\>test-tcpconnection -Computername remotehost -port 3389

This example will make a connection to the computer with name “remotehost” on port 3389

————————– EXAMPLE 2 ————————–

PS C:\>test-tcpconnection -Computername http://www.mysmtpserver.com -service SMTP

This example will make a connection to the computer with name “www.mysmtpserver.com” on the smtp port (25).