Si está abierto parece que no hay resultado
$tcpobject = New-Object System.Net.Sockets.TcpClient
$connect = $tcpobject.BeginConnect("127.0.0.1",25,$null,$null)
# wait for the connection no longer than $timeoutMilliseconds
$wait = $connect.AsyncWaitHandle.WaitOne($timeoutMilliseconds,$false)
$tcpobject.EndConnect($connect)
Si no está abierto hay resultado
$tcpobject = New-Object System.Net.Sockets.TcpClient
$connect = $tcpobject.BeginConnect("127.0.0.1",215,$null,$null)
# wait for the connection no longer than $timeoutMilliseconds
$wait = $connect.AsyncWaitHandle.WaitOne($timeoutMilliseconds,$false)
$tcpobject.EndConnect($connect)