Newer OS Powershell:
Test-NetConnection -ComputerName <remote server> -Port nnnn
Older OS Powershell:
$t = New-Object System.Net.Sockets.TcpClient 'my.hostname', 123; if($t.Connected) {"OK"}
Newer OS Powershell:
Test-NetConnection -ComputerName <remote server> -Port nnnn
Older OS Powershell:
$t = New-Object System.Net.Sockets.TcpClient 'my.hostname', 123; if($t.Connected) {"OK"}