Test-NetConnection to check if specific port is open in windows


In the world of networking, the ability to determine whether a specific port is open on a remote server or host is crucial. Whether you are a system administratWindowseveloper, or an IT enthusiast, understanding port connectivity can help you diagnose network issues and ensure seamless communication between devices. In this article, we will explore the Test-NetConnection command in Windows, a powerful tool that allows you to testWindowspecific port is open on a target machine.

Understanding Test-NetConnection:

Test-NetConnection is a built-in PowerShell cmdlet introduced in Windows 8 and Windows Server 2012. It is designed to diagnose network connectivity by sending various types of network packets to a destination host. By default, the cmdlet checks for TCP connectivity to a specified IP address or hostname. However, it can also perform tests for UDP and ICMP protocols.

Checking a Specific Port in Windows:

Often, you may need to verify whether a particular port is accessible on a remote machine, especially when dealing with services like web servers, FTP servers, or databases. Test-NetConnection comes to the rescue in such scenarios.

To check if a specific port is open on a target machine, you can use the following command:

Test-NetConnection -ComputerName <RemoteHost> -Port <PortNumber>

Replace <RemoteHost> with the hostname or IP address of the remote server and <PortNumber> with the port, you want to check.

How to Use Test-NetConnection Command:

Using Test-NetConnection is straightforward. Open the PowerShell console on your Windows machine, and type the Test-NetConnection command followed by the appropriate parameters.

For instance, to test if port 80 is open on a web server with the IP address, you would execute the following:

Test-NetConnection -ComputerName -Port 80

There are many ways to check whether the specific port is open in our computer, today here I’m going to share the Powershell way on how to check if a specific port is open in windows.

Using Test-NetConnection for Remote Servers:

One of the most significant advantages of Test-NetConnection is its ability to test port connectivity on remote servers. As long as you have network access to the target machine, you can execute the command from your local computer.

This feature proves invaluable in scenarios where you want to verify connectivity to critical ports on servers located in different physical locations or cloud environments

Interpreting Test-NetConnection Results:

Test-NetConnection provides detailed information about the network connectivity test. The output includes the following key pieces of information:

  • ComputerName: The hostname or IP address of the target machine.
  • RemoteAddress: The IP address of the target machine.
  • RemotePort: The port number being tested.
  • InterfaceAlias: The network interface used for the test.
  • SourceAddress: The local IP address from where the test is performed.
  • TcpTestSucceeded: Indicates whether the TCP connection was successful.

By analyzing these details, you can determine if the specified port is open or closed on the remote server.

Test-NetConnection Powershell cmdlet:

Test-NetConnection is the new cmdlet introduced by Microsoft in PowerShell 4.0 version i.e. from windows 8 and windows server 2012 operating system this cmdlet is used to check network connectivity like ping, traceroute, and port check.

Get-Help Test-NetConnection

The above command will provide us with the syntax and usage of Test-NetConnection.

Test-NetConnection -ComputerName Google.com

From the above command, we just tried to query the connectivity to google.com, if the output returns the status as true means the connection is getting succeeded, whereas if connectivity fails then the output returns the status as false.

Test-NetConnection -ComputerName Google.com -Port 80

Here from the above command, we are testing whether the specific port 443 is open on the computer named google.com (just for testing) you should use the remote computer name that you’re trying to query in this field, if the output returns the status as true then the specific port is open on the computer, whereas if output returns the status as false then the specified port is not open in a particular computer.

Test-NetConnection -ComputerName Google.com -CommonTCPPort HTTP

We can even check the port open details by name i.e using the CommonTCPPort parameter as listed in the abothe ve screenshots but it only supports the following HTTP, RDP, SMB, and WINRM for the rest of the ports we need to use the Port parameter Windowsd by a port number as listed in the previous example.

Test-NetConnection -ComputerName Google.com -Port 443 -InformationLevel Detailed

This command supports a parameter called InformationLevel which provides a few more details for the query we execute, refer to the above screenshot that shows a few more details while we tried to query google.com using port 443 with and without InformationLevel parameter.

Hope this article helps to solve your query on how to check if a specific port is open in windows, execute this script at your own risk as we do not provide any guarantee or warranty.

Advanced Usages of Test-NetConnection:

Apart from testing port connectivity, Test-NetConnection can be leveraged for other purposes. For example, you can use it to measure network latency, check if a specific URL is accessible, or perform traceroute-like operations using the -TraceRoute parameter.

Experimenting with the various options provided by Test-NetConnection can enhance your understanding of network troubleshooting.


Test-NetConnection is an invaluable utility for network administrators and enthusiasts alike. It simplifies the process of checking if a specific port is open on a remote server and provides valuable insights into network connectivity.

By using this powerful cmdlet responsibly, you can identify and resolve network-related issues promptly, ensuring smooth communication between devices and services.


Q: Can I use Test-NetConnection to check UDP ports?

A: Yes, Test-NetConnection can test UDP ports as well by using the -Udp parameter.

Q: Are there any alternatives to Test-NetConnection in Windows?

A: Yes, you can use Telnet or PowerShell Test-NetConnection equivalent, Test-NetConnection2, on older Windows versions.