cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

PowerShell DNS lookup script

Major credit to KMSigma and mrxinu :

This script is designed to do DNS lookups and provide metrics that result from such a query. The significant part here is that this can handle an entire domain's worth of DNS lookups. I didn't see any form of this today after searching the forums. Naturally as it was written by KMSigma, it's well commented and hopefully self explanatory. I'll copy the script in here as well so it can be seen. This will identify the fastest, average, and slowest DNS lookups across all available defined DNS servers.

Example results:

Message.Fastest:(hostname) executes DNS lookup against 'www.solarwinds.com' in 0.2371 ms

Statistic.Fastest:0.2371

Message.Average:Average DNS lookups against 'www.solarwinds.com' takes 10.1321466666667 ms

Statistic.Average:10.1321466666667

Message.Slowest:(hostname) executes DNS lookup against 'www.solarwinds.com' in 147.0255 ms

Statistic.Slowest:147.0255

pastedImage_0.png

Labels (1)
Attachments
Comments

Is there a version of this that works with DNS Servers that are not Microsoft and run in Linux?

Not sure what would need to be done. KMSigma​? A new challenger appears!

If you can get a list of DNS servers via PowerShell, then that should be no problem.  The .NET calls (that query DNS) are the same regardless of what operating system runs the DNS stuff.

Hi All,

As per https://social.msdn.microsoft.com/forums/en-US/8b5fe9a3-5da0-41e0-a7f9-2cb6c5608f69/specifying-the-n...

The System.Net.Dns.GetHostEntry() will only be using the existing DNS server configured on the host DNS cache entry.

Therefore, it is best to use Resolve-DNSName cmdlet https://docs.microsoft.com/en-us/powershell/module/dnsclient/resolve-dnsname?view=win10-ps

Please correct me if I'm wrong.

Shamelessly yoinked this. Cheers @KMSigma & @designerfx!

Version history
Revision #:
1 of 1
Last update:
‎05-14-2019 02:29 PM
Updated by: