PowerShell - Resolve entire subnet IP to Hostnames
- Jon Boyette
- Jan 25, 2022
- 1 min read
Copy and paste in PowerShell window, Or save as a self named .ps1, enter subnet to discover as 10.10.10. making certain of the last period, Resolves ALL 255 range to names
$A = Read-Host "Enter Subnet to walk through 255 range (ex 10.10.202.) resolving live IP to hostname"
$net = "$A"
0..255 | foreach {$r=(Resolve-DNSname -ErrorAction SilentlyContinue $net$_ | ft NameHost -HideTableHeaders | Out-String).trim().replace("\s+","").replace("`r","").replace("`n"," "); Write-Output "$net$_ $r"} | tee c:\temp\ip_hostname.txt
Comments