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

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 specific port is open in windows.

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.

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

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

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 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 particular computer.

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

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

 

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

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.