$port = (enter port value)
$network = âenter network valueâ
$range = 1..254
$ErrorActionPreference= âsilentlycontinueâ
$(Foreach ($add in $range)
{ $ip = â{0}.{1}â âF $network,$add
Write-Progress âScanning Networkâ $ip -PercentComplete (($add/$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 openâ
$socket.Close() }
else { â$ip port $port not open â }
}
}) | Out-File C:\reports\portscan.csv