Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Resolve a Subnet (dirty)
Function Get-SubnetResolution {
$Subnet = '74.125.228' #change this
$Wait = 2 #Seconds to wait between resolution
$HostRangeLow = 1
$HostRangeHigh = 10
$Range = $HostRangeLow..$HostRangeHigh
#Instantiate once
$DnsObject = [Net.DNS]
Foreach ($TargetHost in $Range) {
$IPAddress = $Subnet + '.' + $TargetHost
$Resolved = $DnsObject::GetHostEntry("$IPAddress")
$ObjectProps = @{'Hostname' = $Resolved.HostName;
'IP Address' = $Resolved.AddressList}
$Results = New-Object -TypeName PSObject -Property $ObjectProps
Write-Output $Results
Start-Sleep -Seconds $Wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.