Home » PowerShell » Powershell DNS.Reverse.Lookup Script (using System.Net.DNS object)

Powershell DNS.Reverse.Lookup Script (using System.Net.DNS object)


I was given a project to check the 450+ servers’ DNS reverse records/entries.

I thought; let’s try something with PowerShell, after some research on Google and MSDN. I found .Net object (System.Net.DNS), which can be usable in Powershell to complete this job. After few trials/errors I could get the reverse DNS entries by IP.

I’m sharing my script with you folks.  HTH

###########################################################################
#
# NAME: DNS.Reverse.Lookup
#
# AUTHOR:  Malek Jakir
#
# COMMENT: This scrip can be used to get the DNS reverse entry from the DNS server.
# put the IP address as one per line in .txt file. Result will be generated in CSV file.
# VERSION HISTORY:
# 1.0 10/27/2011
#
###########################################################################
get-content “C:\IPs.txt” | ForEach-Object {
[System.Net.Dns]::GetHostbyAddress($_) |
Add-Member -Name IP -Value $_ -MemberType NoteProperty -PassThru
} | Select IP, HostName | Export-CSV .\ReverseLookup.csv -NoTypeInformation

About these ads

4 Comments

  1. na says:

    Errors out.

  2. Love it when people really know .net (which I dont!) all i needed for my script was [System.Net.Dns]::GetHostbyAddress($_) and bingo I was done. Worked like a charm . Thanks much for the post!

  3. Johna206 says:

    Thank you for your blog article. Great. ffekfcafedee

  4. Johnk107 says:

    Dead written subject material, Really enjoyed studying. kfkdfegkdckd

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: