scan IP addresses using PowerShell in Windows

  • Author: Admin
  • Published On: 3/18/2026
  • Category: editor

scan a range of IPs (Ping sweep)


$ProgressPreference = "Continue"
$total = 254
$alive = @()
for ($i = 1; $i -le 254; $i++) {
    $ip = "192.168.18.$i"
    Write-Progress -Activity "Scanning Network" `
                   -Status "Scanning $ip ($i/$total)" `
                   -PercentComplete (($i / $total) * 100)
    if (Test-Connection -ComputerName $ip -Count 1 -Quiet -ErrorAction SilentlyContinue) {
        $alive += $ip
    }
}
Write-Progress -Activity "Scanning Network" -Completed
Write-Host "`nScan complete:" -ForegroundColor Cyan
$alive | ForEach-Object { Write-Host "[+] $_ is alive" -ForegroundColor Green }

Result:

Scan complete:
[+] 192.168.18.1 is alive
[+] 192.168.18.4 is alive
[+] 192.168.18.6 is alive
[+] 192.168.18.22 is alive
[+] 192.168.18.88 is alive
  • Share On: