Thursday, March 30, 2017

Enumerate and Check DNS Records between two Windows DNS Servers

I love powershell scripting as I like games. Today, I finished up the script that I've been writing these days which is the checker of 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.
Fig-1: Running the script on Server 2008R2
Fig-2: Running the script on Server 2012R2


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.