Skip to main content

PowerShell Test Port Forwarding - check if port is open


Port forwarding is necessary if the device is that needs to connect to the unsecured world of the Internet.

Of course, before opening port or doing any port forwarding make sure that security is in place. Firewall rules, software configuration are properly set, up-to-date anti-virus and other settings that needs to be done to secure the system.

PowerShell can test whether a remote port is open or a Port Forwarding rules on either on the Firewall or router is set correctly.

Here’s a one liner code, to check whether the Port is open or not.

Both one line code below does the same thing, check whether the Port is open or not.

1 . New-Object System.Net.Sockets.TCPClient -ArgumentList "Remote.Public.IP.Address", 3389


2. Test-NetConnection -Port 80 -InformationLevel Detailed


Replace the port number, with any port number to be tested.

If the connected property on the displayed output is true, then the port is open.


More details on the link below:

No need, for a third-party website just to check for port connectivity. PowerShell can do it right on your workstation or computer.


Cheers..till next time..happy scripting.

================================
Free Android Apps:

Click on links below to find out more:

Multiplication Table for early learners


Catholic Rosary Guide  for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully. 
https://play.google.com/store/apps/details?id=com.myrosaryapp

http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html

Divine Mercy Chaplet Guide (A Powerful prayer) BFF = Be Filled Faith:

Comments