How to check Network port access and display useful message?

Samselvaprabu picture Samselvaprabu · Mar 5, 2012 · Viewed 180.9k times · Source

I was trying to check whether the port is opened or not using powershell like follows.

(new-object Net.Sockets.TcpClient).Connect("10.45.23.109", 443)

This method works , but the output is not user-friendly. It means if there are no errors then it has access. Is there any way to check for success and display some message like " Port 443 is operational"?

Answer

SimonOzturk picture SimonOzturk · Sep 19, 2014

If you're running Windows 8/Windows Server 2012 or newer, you can use the Test-NetConnection command in PowerShell.

Ex:

Test-NetConnection -Port 53 -ComputerName LON-DC1