title: How can I automate Telnet port checking in Powershell?`
body: <p>I'm currently trying to put together a script that queries AD for a list of computers, pings the computers to determine which ones are still active, and then telnets into a specific port on all the pingable computers. The output I'm looking for is a full list of pingable computers in AD for which I can't telnet to the said port.</p>
  
  <p>I've read <a href="https://stackoverflow.com/questions/20583686/automate-telnet-port-testing-on-windows-7-using-batch-script">these</a> <a href="https://stackoverflow.com/questions/709801/creating-a-script-for-a-telnet-session">few</a> <a href="https://stackoverflow.com/questions/613508/how-can-i-automate-telnet-port-25-testing">questions</a>, but they don't quite hit on what I'm trying to do. I just want to see if the telnet connection is successful without entering telnet (or automate the quitting of telnet) and move on to the next machine to test. The AD and pinging portions of my script are set, I'm just stuck here. The things I've tried haven't quite worked as planned.</p>
  
  <p>Here is the code for the first parts of the script, if needed:</p>
  
  <pre><code>Get-ADComputer -Filter * -SearchBase 'DC=hahaha,DC=hehehe' | ForEach {
  
  $computerName = $_.Name
  
  $props = @{
      ComputerName = $computerName
      Alive = $false
      PortOpen = $false
  }
  
  If (Test-Connection -ComputerName $computerName -Count 1 -Quiet) {
  
      $props.Alive = $true
  }
  </code></pre>