Test Internet Connectivity through Specified Ports

Hello, I am fairly new to the PowerShell ways…

Is there a way to test connectivity to a website through specified ports (80 and 443)? Test-NetConnection seems to just let you specify the port of the remote machine for testing. I would like to specify the port (80 and 443) that I am using to test internet connectivity. I assume 80 is used by default in most cases, but how about 443?


Sure! Try the following code.

test-netconnection -ComputerName "www.google.com" -Port 443 -InformationLevel Detailed

Modify the -ComputerName argument with a website of your choice. Can be with the www. or without.

Thank you. This works good when testing the remote machines port. But, I am trying to test connections through the local machines port(s). The goal is to see if ports on local machines are open and can reach websites. I have had no luck finding this concept in any of the normal functions in PowerShell.

So, I am basically trying to connect through both my local machines ports 80 and 443, and see if I can hit a website. I would appreciate any tips that can be provided. Thank you!!


Adam, that is not how it works. Most client applications (including web browsers) rely on the operating system to dynamically assign a local port out of a defined ephemeral range (since Windows Vista from 49152 to 65535) for outbound communication.

You can see that using the netstat command.

netstat -an -p tcp

For example, if you hit https://www.google.com in Chrome. Chrome will use an operating system API to establish a TCP connection to the IP address of www.google.com and port 443. Chrome won’t tell the operating system which local port to use because a local port can only be used (bound) by one application at a time. If multiple browsers or tabs would try to use the same local port one of them would fail and present an error message to the user which of course is a bad experience.

Only certain client applications bind to a specific local port for outbound connections like Skype to bypass a firewall. Binding to port 80, 443 or other is generally a behaviour of server applications like web servers where someone needs to know the port to access a service from the outside.

I hope that helps.

Thanks all! I’m taking this knowledge back to the script requestor for further clarification. I really appreciate all the feedback.