top of page

PowerShell - Discover IP to Hostname (Uses Get-DNSServerResourceRecord)

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 6, 2022
  • 1 min read

Updated: Jan 7, 2022



$zone = 'Enter Your Domain'

$range = 'xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx' #Enter your range



function Addr2UInt($addr) {

$bytes = $addr.GetAddressBytes()

[array]::Reverse($bytes)

[BitConverter]::ToUInt32($bytes, 0)

}


$addrFrom = Addr2UInt ([Net.IPAddress]::Parse($range[0]))

$addrTo = Addr2UInt ([Net.IPAddress]::Parse($range[1]))


Get-DNSServerResourceRecord $zone -RRType 'A' | ? {

$addr = Addr2UInt $_.RecordData.IPv4Address;

$addrFrom -le $addr -and $addr -le $addrTo

}


Then can Out-File or Export-csv for this




 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page