Enumerate and Check DNS Records between two Windows DNS Servers

Update on 22.May.2023 : I do not review my scripts regularly. Thanks to Frank Dub  who modified the script by removing the Server 2008 execution code and fixed the PTR record section, which was not working properly. You can find it as the latest script with version 1.1 attached in this post. For the previous version, see here.

———————————————————————————————————–

Today, I finished up the script which can check the DNS records between two DNS servers. Powershell DNS Client module is only available from Windows 8, Server 2012/R2, which makes powershellers easy for dns query & administration. But as I want to include the old server 2008 in this scenario, I scripted the ‘nslookup’ command in this script.

You will just need to put the -DestinationServer parameter for the server you want to query. Also, the records of local dns server will be enumerated.
Open the powershell console in elevated mode and run the following command to the script.
.\Check_DNS_Records_Status -DestinationServer  myServerNameOrIP | ft -auto
You can export the comparison of enumerated records into the csv file (which you can open with the excel) with the following command.
.\Check_DNS_Records_Status -DestinationServer  myServerNameOrIP | Export-Csv -Notype DNS_Compare_Results.csv
Figure-1 is when I run the script on server 2008R2 and Figure-2 is on the server 2012R2 machine.
Technical Note: When you are running the script on Server 2008/2008R2 and there are so many unavailable records on the destination server, it might take quite a long-time to get the responses from the destination server. For this case, I included the powershell job function to save time, which will be run when the first 2 query each takes more than 500ms. I found that creating too many powershell jobs consumes large amount of memory, each job with ~30MB. So, I also included the -NumberOfJobs parameter to restrict the jobs that are allowed to run. By default, it is 10 jobs per session.

Running the script on Server 2008R2

Fig-1: Running the script on Server 2008R2

 
Running the script on Server 2012R2

Fig-2 Running the script on Server 2012R2

You can download my script from github.

This entry was posted in DNS, Powershell. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *