-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNetwork Connectivity Test
51 lines (46 loc) · 1.88 KB
/
Network Connectivity Test
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
#Why have you forsaken me ISP?
ping bing with extra steps
#by David Lee
#made for when my isp is mad at me
#clears dns cache, pings a target site, and displays the results
#if you use this, update lines ~41-49 to update the dumpfile
#clear dns cache as a precaution
Clear-DnsClientCache
#checks and or sets target
if ($null -eq $Target ) {
#if variable does not exist, make variable
New-Variable -Name "Target" -Value "Bing.com"
#Write-Host "target variable created"
##uncomment for debugging
}
elseif ($null -ne $Target) {
Write-Host "target site is"$Target -ForegroundColor Gray
}
#counts total pings
if ($null -eq $Counter) {
#if variable does not exist, make variable
New-Variable -Name "Counter" -Value 0
#Write-Host "counter variable created"
##uncomment for debugging
}
elseif ($null -ne $Counter) {
#reset counter to 0
$Counter = 0
#Write-Host "counter variable reset"
##uncomment for debugging
}
while ($Counter -lt 500) {
#if I forget this is running, this will prevent it from going on forever
Start-Sleep -Seconds 3
Test-Connection bing.com > C:\Users\David\Documents\pingBingDump.txt #&& ConvertTo-Csv C:\Users\David\Documents\pingBingDump.csv
#output to txt and csv
Get-Content C:\Users\David\Documents\pingBingDump.txt -First 4 | Write-Host -ForegroundColor White
#Test-Connection bing.com > C:\Users\David\Documents\pingBingDump.txt #temporary dumpfile
#Get-Content C:\Users\David\Documents\pingBingDump.txt -First 4 | Write-Host -ForegroundColor White
#if run into errors, diagnose by changing line 4 > to >> and see what is being written in pingBingDump
get-date | Write-Host -ForegroundColor Gray
$Counter += 1
Write-Host count: $Counter -ForegroundColor Red
}
write-host "Max ping count reached"
#https://devblogs.microsoft.com/scripting/powertip-read-first-line-of-file-with-powershell/