CompTIA PT0-003 Question Answer
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?
CompTIA PT0-003 Summary
- Vendor: CompTIA
- Product: PT0-003
- Update on: Mar 15, 2026
- Questions: 298

