Telnet equivalent in Powershell

Powershell doesn’t come with telnet by default, however you can use the following command to quickly connect to a TCP server in a Powershell window.

This can be used to quickly check if a certain IP address / port is reachable (such as port 80 for HTTP).

Open up a Powershell window and enter the following command:

New-Object System.Net.Sockets.TcpClient("google.com", 80)

If the TCP connection is succesful, you should see the following output:

Client              : System.Net.Sockets.Socket
Available           : 0
Connected           : True
ExclusiveAddressUse : False
ReceiveBufferSize   : 65536
SendBufferSize      : 64512
ReceiveTimeout      : 0
SendTimeout         : 0
LingerState         : System.Net.Sockets.LingerOption
NoDelay             : False

If you do not see anything or the screen hangs, it most likely indicates a timeout.

Note: you cannot send any commands over the TCP connection this way (for that you would need to create a Powershell script). However for quick connect tests this method is sufficient.

Published
Categorized as Powershell

By Leendert de Borst

Freelance software architect with 10+ years of experience. Expert in translating complex technical problems into creative & simple solutions.

Leave a comment

Your email address will not be published.