# try and establish a connection to port async $tcpobject = New-Object System.Net.Sockets.TcpClient $connect = $tcpobject.BeginConnect($computername,$port,$null,$null)
# wait for the connection no longer than $timeoutMilliseconds $wait = $connect.AsyncWaitHandle.WaitOne($timeoutMilliseconds,$false)