PowerShell - Port Scanner, can define whatever ports to check, prompts for machinename save to .ps1
- Jon Boyette
- Jan 6, 2022
- 1 min read
Updated: Jan 7, 2022
This particular one liner makes short work of seeing what ports you want to defined open or closed. save this as a .ps1 and prompts for servername, Nice Port Scanner
$Server = Read-Host -Prompt 'Input your target IP/host' ; 80, 135, 445, 3389, 5985 | % {$test= new-object system.Net.Sockets.TcpClient; $wait = $test.beginConnect("$Server",$_,$null,$null); ($wait.asyncwaithandle.waitone(250,$false)); if ($test.Connected){echo "$_ open"}else{echo "$_ closed"}} | select-string " "
Comments