Loop through ports 1–1024, try to open a TCP connection using .NET sockets and prints which ports respond.
1..1024 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("192.168.173.151", $_)) "TCP port $_ is open"} 2>$nullLoop through ports 1–1024, try to open a TCP connection using .NET sockets and prints which ports respond.
1..1024 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("192.168.173.151", $_)) "TCP port $_ is open"} 2>$null