Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###################################
- # Reidar J. Boldevin - 22.05.2014 #
- # The Tech Depot #
- # http://www.boldevin.com #
- ###################################
- # Collect human error
- $target = Read-Host "What is the target name or IP?"
- $startport = Read-Host "What is the starting port?"
- $endport = Read-Host "What is the ending port?"
- # Translate human error to working script variables
- $range = $startport..$endport
- $result =@()
- # Test each port
- foreach ($port in $range) {
- $result += Test-NetConnection -ComputerName $target -Port $port
- }
- # Format output
- $format = @{Expression={$_.RemotePort};Label="Remote Port";width=13},
- @{Expression={$_.TcpTestSucceeded};Label="Port Open";width=11},
- @{Expression={$_.PingSucceeded};Label="Target available";width=18}
- # Show the code monkey the fruits of his labor
- $result | ft $format
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement