-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimulate_webtestconnection.ps1
25 lines (22 loc) · 1.07 KB
/
simulate_webtestconnection.ps1
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
#This script works for PS version 3 and above tested on Windows 10
#GPL v2
#author: Dennis Chow 20-March-2020 <dchow[AT]xtecsystems.com>
while($true)
{
$domains = @("www.google.com", "www.yahoo.com", "www.cnn.com", "www.xfinity.com", "dl.google.com")
$useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
$getwebpage = Invoke-WebRequest -Uri $domains[$(Get-Random -Minimum 0 -Maximum $domains.Count)] -TimeoutSec 5 -UserAgent $useragent
Start-sleep -Seconds 1
#$inetstatus = Test-NetConnection -ComputerName $domains[$(Get-Random -Minimum 0 -Maximum $domains.Count)] -Port 443
$inetstatus = Test-NetConnection -ComputerName "dl.google.com" -Port 443
if ($inetstatus.TcpTestSucceeded -ne 0)
{
Write-Host "$i works"
}
elseif ($inetstatus.TcpTestSucceeded -eq 0)
{
Write-Host "$i failed"; "failed" | Out-File -Append status.txt
}
$randomint = Get-random -Minimum 120 -Maximum 300
Start-Sleep -Seconds $randomint
}