top of page

PowerShell - Port Scanner, can define whatever ports to check, prompts for machinename save to .ps1

  • Writer: Jon Boyette
    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 " "



 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page