The classic answer to “is that port open?” used to be installing telnet. PowerShell has a built-in check.
Test-NetConnection -ComputerName example.com -Port 443
Test-NetConnection example.com -Port 443 -InformationLevel Quiet
The result shows the name resolution, the ping reply and then TcpTestSucceeded, which is True when the connection to that port worked. With -InformationLevel Quiet you only get True or False, which suits scripts.
-CommonTCPPort accepts a few service names instead of a number, such as HTTP, RDP, SMB and WINRM, so -CommonTCPPort RDP tests port 3389.
I find it useful when something works from one network and not from another, because you can run the same command on both and compare the answers.
The caveat is that the cmdlet always runs a ping test and name resolution too, even when you only care about the port. A PingSucceeded of False does not mean the TCP test failed, since many hosts block ping. Read TcpTestSucceeded for the port. A False there can mean nothing is listening, or a firewall or the network blocks it, and the cmdlet cannot tell you which.
Further reading: Microsoft Learn: Test-NetConnection