To quickly test if you can communicate with a server on a specific port use this command: Test-NetConnection (hostname/ip) -Port (tcp port number) You are looking for TcpTestSucceeded : True in the output.
Example: PS C:\Users\Clint> Test-NetConnection www.google.com -port 80
ComputerName : www.google.com RemoteAddress : 188.8.131.52 RemotePort : 80 InterfaceAlias : vEthernet (LAN) 2 SourceAddress : 192.168.0.5 TcpTestSucceeded : True
This command is quite flexible, you can also have it test with ICMP like PING and Trace Route.
Does not appear to support UDP test, in PowerShell 5…
This command doesn’t appear to be in PowerShell Core/PowerShell 6. However, Test-Connection is. It has some different options, I haven’t read all of them, but it appears to be more flexible, however, to get the same result as above run: Test-Connection www.googgle.com -TCPPort 80
When you check a specific port, it will return a True or False - in my testing it performs this check quickly