PowerShell vs CommandLine – Determining Open Ports
As a networking professional one thing that is recurrent is determining if a port is open. If you are changing access-list you need to be able to determine the age old question can this IP get to that IP on this port. Let’s keep it simple, there are a couple easy ways to do this:
1) Microsoft Telnet client
2) Powershell command line
Microsoft Telnet client
First things first Telnet doesn’t come installed by default on Windows 10. To determine if the telnet client is installed go to the cmd promt and type: telnet 8.8.8.8
If the result is:
“telnet’ is not recognized as an internal or external command, operable program or batch file.”
You now know that Telnet is not installed. So open a the CMD.exe as an administrator and run:
dism /online /Enable-Feature /FeatureName:TelnetClient
This will install the Telnet client.
How do you use it?
Let look at the following example: You want to see if a website is accepting http or port 80 you would type in the domain space 80:
Then hit enter. If a connect is made the screen will go blank:
To get out of this you hit “Ctrl” & ] or “Ctrl” & } this will disconnect the session:
To exit the client. Just type “quit” and hit enter and you are back at the CMD prompt.
Similar to what was done there you can substitute the Domain Name for an IP address this is handy if you feel the problem is DNS.
PowerShell
PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language. To open PowerShell in the search area type “powershell” and Windows PowerShell will pop up.
Similar to using the Telnet Client the test for Google port 80 would be as follows type the following:
Test-NetConnection -ComputerName google.com -Port 80
A positive result would be:
And if you wanted to test via the IP address you would enter:
The result would be:
In the end both utilizing the telnet client and Powershell will yield the same results however it may be more favorable to use one or the other depending on the situation.