Advertisement
opexxx

portscanps.ps

May 27th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###################################
  2. # Reidar J. Boldevin - 22.05.2014 #
  3. # The Tech Depot                  #
  4. # http://www.boldevin.com         #
  5. ###################################
  6.  
  7. # Collect human error
  8. $target = Read-Host "What is the target name or IP?"
  9. $startport = Read-Host "What is the starting port?"
  10. $endport = Read-Host "What is the ending port?"
  11.  
  12. # Translate human error to working script variables
  13. $range = $startport..$endport
  14. $result =@()
  15.  
  16. # Test each port
  17. foreach ($port in $range) {
  18.     $result += Test-NetConnection -ComputerName $target -Port $port
  19.     }
  20.  
  21. # Format output
  22. $format = @{Expression={$_.RemotePort};Label="Remote Port";width=13},
  23. @{Expression={$_.TcpTestSucceeded};Label="Port Open";width=11},
  24. @{Expression={$_.PingSucceeded};Label="Target available";width=18}
  25.  
  26. # Show the code monkey the fruits of his labor
  27. $result | ft $format
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement