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 '' in 0.2371 ms


Message.Average:Average DNS lookups against '' takes 10.1321466666667 ms


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



Labels (1)

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

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

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: