Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's a shame you can't use netcat - are all open source options like it off-limits in your environment?</p> <p>Even without open source tools, you can still accomplish this task with PowerShell.</p> <p>Here's a sample PS script that will try to connect to port 23 on $remoteHost and exit 0 on success, and 1 on failure. (If you need to do more work once connected, a few examples of more complex PowerShell telnet clients are available on the web, such as <a href="http://thesurlyadmin.com/2013/04/04/using-powershell-as-a-telnet-client/" rel="nofollow noreferrer">this one</a>.)</p> <p>Place the code in the file "foo.ps1", then run in cmd.exe (or from a .bat file) with "<strong>powershell -File foo.ps1</strong>". When it exits, the exit code will be stored in %errorlevel%.</p> <p>Note you may need to modify your PowerShell script execution policy (or use the <a href="https://stackoverflow.com/a/9167524/267263">"-ExecutionPolicy Bypass" cmdline option</a>) to allow execution of the script - for more info see <a href="http://technet.microsoft.com/en-us/library/ee176949.aspx" rel="nofollow noreferrer">this documentation from MSFT</a>.</p> <pre><code>param( [string] $remoteHost = "arbitrary-remote-hostname", [int] $port = 23 ) # Open the socket, and connect to the computer on the specified port write-host "Connecting to $remoteHost on port $port" try { $socket = new-object System.Net.Sockets.TcpClient($remoteHost, $port) } catch [Exception] { write-host $_.Exception.GetType().FullName write-host $_.Exception.Message exit 1 } write-host "Connected.`n" exit 0 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload