Created
February 2, 2015 18:16
-
-
Save obscuresec/104edc53459715214226 to your computer and use it in GitHub Desktop.
Resolve a Subnet (dirty)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} | |
Get-SubnetResolution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment