Monday, 1 March 2021

HOW TO RESOLVE MULTIPLE DNS ENTRY AT ONCE

 HOW TO RESOLVE MULTIPLE DNS ENTRY AT ONCE


Forward Lookup

File format








$Hostname1 = Get-Content C:\Users\Administrator\Desktop\Hostname.txt

$result =

foreach ($Hostname in $Hostname1){

    Write-Verbose "Resolving $Hostname " -Verbose

    $dns = [System.Net.Dns]::GetHostEntry($Hostname)

    $dns | Select-Object HostName,

    @{n='AddressList';exp={$_.AddressList.IPAddressToString}}

}

$result | export-csv C:\Users\Administrator\Desktop\dnsresult.csv -NoTypeInformation  



Reverse Lookup

File format







$IP1 = Get-Content C:\Users\Administrator\Desktop\ip.txt

$result =

foreach ($ip in $IP1){

    Write-Verbose "Resolving $ip" -Verbose

    $dns = [System.Net.Dns]::GetHostEntry($ip)

    $dns | Select-Object HostName,

    @{n='AddressList';exp={$_.AddressList.IPAddressToString}}

}

$result | export-csv C:\Users\Administrator\Desktop\dnsresult.csv -NoTypeInformation 

No comments:

Post a Comment