$socket = new-object Net.Sockets.TcpClient
$socket.Connect($IPAddress,$Port)
$socket.Connected
Details
Just supply an IP Address and Port number and it will return true or false, based on if it was able to connect.