PowerShell - Discover Entire Subnet (Read-Host)
- Jon Boyette
- Jan 13, 2022
- 1 min read
Save as a subnetinfo.ps1 or self named, This will step through every subnet through 255 and if there is a DNS entry will resolve to hostname.
$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