Which version of Windows? For Windows 8/Server 2012 and later, the following works in PowerShell:
Test-NetConnection 128.159.1.1 -Port 80
Some Googling will also turn up alternatives which use the .NET Framework directly (since PowerShell lets you do that) for systems running lower versions of Windows that won't have Test-NetConnection available.
If you're not averse to using third-party utilities, Nmap is also a very good friend to have and it works from the command line.
"Portqry.exe is a command-line utility that you can use to help troubleshoot TCP/IP connectivity issues. Portqry.exe runs on Windows 2000-based computers, on Windows XP-based computers, and on Windows Server 2003-based computers. The utility reports the port status of TCP and UDP ports on a computer that you select. "
Which version of Windows? For Windows 8/Server 2012 and later, the following works in PowerShell:
Some Googling will also turn up alternatives which use the .NET Framework directly (since PowerShell lets you do that) for systems running lower versions of Windows that won't have
Test-NetConnection
available.If you're not averse to using third-party utilities, Nmap is also a very good friend to have and it works from the command line.
I found a hiddem gem the other day from Microsoft that is designed for testing ports:
Portqry.exe
"Portqry.exe is a command-line utility that you can use to help troubleshoot TCP/IP connectivity issues. Portqry.exe runs on Windows 2000-based computers, on Windows XP-based computers, and on Windows Server 2003-based computers. The utility reports the port status of TCP and UDP ports on a computer that you select. "
Use the telnet command to connect to the server on the specified port, and see if a connection can be established.
Success:
Fail:
Telnet will work for TCP.
Netcat is a better tool for these sorts of things, including UDP, watch out though, some AV softwares consider it an 'evil hacker tool'
Use netcat Windows port:
the following command will list all ports in use on the machine...
The output contains the protocol, local address, foreign address and current state
Netstat documentation on microsoft.com
'netstat' is you friend.