title: Powershell TCP port scanner
body: <p>I would like to create a powershell script to perform a TCP port scanner that can list the open TCP ports for a given IP address.
  here is what I did so far, this is not perfect and I would love some feedback and corrections</p>
  
  <pre><code>       port = (80)
         network = (192.168.0)
         ErrorActionPreference= ‘silentlycontinue’
         { $ip = “{0}.{1}” –F $network,$add
         If(Test-Connection –BufferSize 32 –Count 1 –quiet –ComputerName $ip)
         { $socket = new-object System.Net.Sockets.TcpClient($ip, $port)
  </code></pre>
  
  <p>the problem with this is doesn't scan all the TCP port, and I am not sure how to make it do that.</p>