---
title: "Test-NetConnection: check if a TCP port is open in PowerShell"
canonical: https://saasranked.com/guides/test-netconnection-port/
applies_to: Windows, Windows Server 2016, Windows Server 2019, Windows Server 2022, Windows Server 2025
checked: 2026-08-23 (against Microsoft's documentation)
updated: 2026-08-23
---

# Test-NetConnection: check if a TCP port is open in PowerShell

- -ComputerName takes the DNS name or IP address of the target computer, and -Port takes the TCP port number on it [1].
- -InformationLevel accepts Detailed or Quiet, and Quiet returns basic information such as a True or False result [1].
- -CommonTCPPort tests a common service port by name, and it accepts HTTP, RDP, SMB or WINRM [1].
- Microsoft's Remote Desktop guide checks port 3389 with Test-NetConnection and -InformationLevel Detailed [2].
- The cmdlet supports ping, TCP, route tracing and route selection tests; -Port is a TCP port [1].

To test whether a TCP port is open, run Test-NetConnection with -ComputerName for the host and -Port for the TCP port number [1]. Add -InformationLevel Detailed to see more fields [1]. Then read the TcpTestSucceeded line. Microsoft's troubleshooting guide says True indicates no connectivity issues, and False indicates connectivity issues [2].

## Syntax

To test a port, use the RemotePort form of Test-NetConnection. `-Port` is required in this form, and the other two parameters are optional [1].

```powershell
Test-NetConnection
    [[-ComputerName] <String>]
    -Port <Int32>
    [-InformationLevel <String>]
```

- `-ComputerName` is the DNS name or IP address of the target computer [1].
- `-Port` is the TCP port number on the remote computer. The cmdlet uses it to test connectivity [1].
- `-InformationLevel` accepts `Detailed` or `Quiet`. Quiet returns basic information, such as a Boolean result [1].

A second form, `-CommonTCPPort`, takes a service name instead of a number. It accepts HTTP, RDP, SMB and WINRM [1]. The cmdlet returns a NetConnectionResults object for both forms [1].

## Examples

### Test a port on a remote computer

This is the test Microsoft's Remote Desktop guide uses. It checks TCP port 3389, the default Remote Desktop port, and shows detailed results [2]. Replace `www.contoso.com` with your host name or IP address.

```powershell
Test-NetConnection -ComputerName www.contoso.com -Port 3389 -InformationLevel Detailed
```

Look for the `TcpTestSucceeded` line in the output. If it is `True`, it indicates no connectivity issues. If it is `False`, it indicates connectivity issues [2].

### See the detailed output in full

Without `-ComputerName`, the cmdlet tests a default server. This example from the reference tests TCP port 80 on it [1].

```powershell
Test-NetConnection -Port 80 -InformationLevel "Detailed"
```

Microsoft shows this output [1]:

```text
ComputerName            : internetbeacon.msedge.net
RemoteAddress           : 2a01:111:2003::52
RemotePort              : 80
NameResolutionResults   : 2a01:111:2003::52
                          13.107.4.52
MatchingIPsecRules      : Ipsec/Domain-TrafficFromInternet-v6
NetworkIsolationContext : Internet
IsAdmin                 : False
InterfaceAlias          : Ethernet
SourceAddress           : 2001:4898:d8:33:81e8:7b49:8bf5:8710
NetRoute (NextHop)      : fe80::200:5eff:fe00:203
TcpTestSucceeded        : True
```

### Get only True or False

Use `Quiet` when a script only needs the result. With Quiet, the cmdlet returns basic information, such as a Boolean value that shows whether the attempt to reach the host or port succeeded [1].

```powershell
Test-NetConnection -ComputerName www.contoso.com -Port 80 -InformationLevel Quiet
```

It returns `True` or `False` [1].

### Test a common service port by name

`-CommonTCPPort` saves you from looking up the number. It accepts HTTP, RDP, SMB and WINRM [1].

```powershell
Test-NetConnection -ComputerName www.contoso.com -CommonTCPPort RDP
```

It returns a NetConnectionResults object, the same type as a `-Port` test [1].

## Common errors

**`TcpTestSucceeded` is `False`.** This indicates connectivity issues [2]. Microsoft's Remote Desktop guide suggests two next checks. First, connect with the IP address instead of the host name. If that works, the problem is likely name resolution. Then check that firewall rules allow the traffic [2].

**You need to test a UDP port.** The cmdlet supports ping, TCP, route tracing and route selection tests. `-Port` takes a TCP port number [1].

**`-Port` and `-TraceRoute` won't work together.** They belong to different forms of the command. `-TraceRoute` is part of the ping (ICMP) form, and `-Port` is part of the RemotePort form [1]. Run them as two separate commands.

**`-CommonTCPPort` rejects your value.** It accepts only HTTP, RDP, SMB and WINRM. For any other service, use `-Port` with the port number [1].

**The test ran against the wrong server.** If you leave out `-ComputerName`, the cmdlet tests a default server, internetbeacon.msedge.net in Microsoft's examples [1]. Name your host with `-ComputerName`.

## Questions

**Does Test-NetConnection need administrator rights?** Microsoft's reference example of a TCP test shows IsAdmin : False next to TcpTestSucceeded : True [1]. Microsoft's Remote Desktop troubleshooting guide does open an elevated PowerShell window for its port test [2].

**What happens if I leave out -ComputerName?** In Microsoft's examples, the cmdlet then tests a default server, internetbeacon.msedge.net [1].

**Can Test-NetConnection test a UDP port?** The reference lists ping, TCP, route tracing and route selection tests, and it describes -Port as a TCP port number [1]. It lists no UDP test.

**How do I get just True or False for a script?** Add -InformationLevel Quiet. With Quiet, the cmdlet returns basic information, such as a Boolean value that shows whether the attempt succeeded [1].

## Sources

1. [Test-NetConnection (NetTCPIP)](https://learn.microsoft.com/en-us/powershell/module/nettcpip/test-netconnection), Microsoft Learn, accessed 2026-08-23
2. [Remote Desktop can't connect to the remote computer](https://learn.microsoft.com/en-us/troubleshoot/windows-server/remote/remote-desktop-cannot-connect-remote-computer), Microsoft Learn, accessed 2026-08-23

Checked against Microsoft's documentation on 23 Aug 2026.
