Spring Sale Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: xmasmnth

A penetration tester gains initial access to a system and gets ready to perform additional...

A penetration tester gains initial access to a system and gets ready to perform additional reconnaissance. The tester cannot use Nmap on the system they used to gain initial access. The tester develops the following script to scan a network range:

$port = 80

$network = 192.168.1

$range = 1..254

$ErrorActionPreference = 'silentlycontinue'

$(Foreach ($r in $range)

{

$ip = "{0}.{1}" -F $network,$r

Write-Progress "Scanning" $ip -PercentComplete (($r/$range.Count)*100)

If(Test-Connection -BufferSize 32 -Count 1 -quiet -ComputerName $ip)

{

$socket = new-object System.Net.Sockets.TcpClient($ip, $port)

If($socket.Connected)

{

"$ip port $port is open"

$socket.Close()

}

else { "$ip port $port is closed" }

}

}) | Out-File C:\nefarious_location\portscan.csv

The tester wants to modify the current script so multiple ports can be scanned. The tester enters a comma-separated list of ports in the port variable. Which of the following should the tester do next to provide the intended outcome?

A.

Duplicate the $socket code block and modify $port for each new port variable.

B.

Add a new Foreach loop directly beneath the other Foreach loop and enclose with { ... }.

C.

Add $p in $port to the initial Foreach loop directly following the $range variable.

CompTIA PT0-003 Summary

  • Vendor: CompTIA
  • Product: PT0-003
  • Update on: Mar 15, 2026
  • Questions: 298
Price: $52.5  $149.99
Buy Now PT0-003 PDF + Testing Engine Pack

Payments We Accept

Your purchase with ExamsVCE is safe and fast. Your products will be available for immediate download after your payment has been received.
The ExamsVCE website is protected by 256-bit SSL from McAfee, the leader in online security.

examsvce payment method