This PowerShell script measures DNS query response times for a list of domains and outputs the results into a CSV file along with basic statistics.
- PowerShell 5.1 or higher
- Read access to a text file containing the list of domains (default:
Domains.txt)
| Parameter | Type | Default | Description |
|---|---|---|---|
$DnsServer |
string |
1.1.1.1 |
DNS server to query |
$QueriesPerDomain |
int |
3 |
Number of queries per domain |
$DomainsFile |
string |
Domains.txt |
Path to the text file with domains |
$ResultsFile |
string |
Results.csv |
Path for the output CSV file |
- Download or copy the script into a
.ps1file. - Adjust the parameters (especially file paths) if necessary.
- Create a
Domains.txtfile in the script directory and list the domains you want to test.
.\v1-
CSV file (
$ResultsFile) with columns:domainβ the queried domain namequeryβ the iteration number of the queryresponse_msβ response time in milliseconds, orERRif the query failed
-
Console output showing each query result and final statistics.
At the end of the script run, it prints:
- Average: average response time (ms)
- Shortest: fastest response time (ms)
- Longest: slowest response time (ms)
# Content of Domains.txt:
example.com
microsoft.com
# Execute the script
.\v1.ps1
# Sample console output:
[example.com] Query 1: 23.45 ms
[example.com] Query 2: 22.87 ms
[example.com] Query 3: 24.12 ms
...
==== Stats ====
Average: 23.48 ms
Shortest: 22.87 ms
Longest: 24.12 msThis script is licensed under the MIT License. See LICENSE for details.
Give it a star β on github!