You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DDI/Measure-DnsServerResponse.ps1
+19-9Lines changed: 19 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -17,22 +17,32 @@ function Measure-DnsResponseTime {
17
17
[Parameter(
18
18
Mandatory,
19
19
Position=0,
20
-
HelpMessage='The DNS server name or IP address to query.')]
20
+
HelpMessage='The DNS server name or IP address to query.'
21
+
)]
21
22
[ValidateNotNullOrEmpty()]
22
23
[string]
23
24
$DnsServer,
24
25
25
26
[Parameter(
26
27
Mandatory,
27
28
Position=1,
28
-
HelpMessage='The domain or host name to resolve.')]
29
+
HelpMessage='The domain or host name to resolve.'
30
+
)]
29
31
[ValidateNotNullOrEmpty()]
30
32
[string]
31
-
$TargetName
33
+
$TargetName,
34
+
35
+
# Number of times to query the DNS server for the target name.
36
+
[Parameter(
37
+
HelpMessage='The number of times to query the DNS server for the target name.'
38
+
)]
39
+
[ValidateRange(1, [int]::MaxValue)]
40
+
[int16]
41
+
$QueryCount=100
32
42
)
33
43
$queryTimes=@()
34
-
Write-Host"Querying DNS server $DnsServer for $TargetName100 times: "-NoNewline -ForegroundColor Green
35
-
for ($i=0; $i-lt100; $i++) {
44
+
Write-Host"Querying DNS server $DnsServer for $TargetName$QueryCount times: "-NoNewline -ForegroundColor Green
45
+
for ($i=0; $i-lt$QueryCount; $i++) {
36
46
Write-Host'.'-NoNewline -ForegroundColor Yellow
37
47
try {
38
48
Clear-DnsClientCache
@@ -45,10 +55,10 @@ function Measure-DnsResponseTime {
45
55
# To Do: Add error handling. Change return to a continue and track how many times it failed, then reduce the result count for the average--but also show a factor for how reliable the server was.
0 commit comments