This topic contains 5 replies, has 4 voices, and was last updated by
January 19, 2017 at 9:33 pm #62181
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?
January 21, 2017 at 7:41 am #62346ParticipantPoints: 0Rank: Member
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.
February 7, 2017 at 7:46 pm #63697
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!!
February 7, 2017 at 8:25 pm #63702ModeratorPoints: 24Rank: Member
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 http://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.
February 7, 2017 at 8:12 pm #63699ParticipantPoints: 21Rank: Member
February 7, 2017 at 8:50 pm #63705
Thanks all! I'm taking this knowledge back to the script requestor for further clarification. I really appreciate all the feedback.
The topic ‘Test Internet Connectivity through Specified Ports’ is closed to new replies.