-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDNSTest.ps1
More file actions
83 lines (55 loc) · 2.47 KB
/
DNSTest.ps1
File metadata and controls
83 lines (55 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$timestamp = Get-Date -Format o | ForEach-Object { $_ -replace ":", "." }
cd "$env:USERPROFILE\Downloads"
Write-Output "###################################" | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
Write-Output " Starting Network Diagnostic Log " | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
Write-Output "###################################" | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
Write-Output $timestamp | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
# Check DNS Queries to these.
$nslookups = @(
"sip.pstnhub.microsoft.com",
"google.com",
"facebook.com",
"apple.com"
)
$pings = @(
"8.8.8.8",
"10.123.123.123")
$systemtime = systeminfo | findstr /C:“Time Zone”
Write-Output $systemtime | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
while(1){
$date = Get-Date
# Record Date and Time
#Write-Output $date | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
# DNS Checks
ForEach ($nslookup in $nslookups) {
# Use Default DNS Server
Write-Output "nslookup $nslookup"
$result = nslookup $nslookup
#$result
$test = $result | Select-String -Pattern "Addresses:|Aliases:"
#Write-Output $test
$date = Get-Date
if ($test){
$testresult = "$date $nslookup OK"
#Write-Output $testresult
$testresult | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
}else{
$testresult = "$date $nslookup Failed"
#Write-Output $testresult | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
$testresult | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
Write-Output "$date nslookup $nslookup 1.1.1.1"
$result = nslookup $nslookup 1.1.1.1
$result | Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
# IPv4 Internet Reachablity Checks
ForEach ($ping in $pings) {
Write-Output "ping $ping"
$result = ping $ping
$result |Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
#Write-Output "tracert $ping"
#$result = tracert $ping
#$result |Tee-Object -FilePath .\ProblemLog-$timestamp.txt -Append
}
}
}
Start-Sleep -s 5
}