mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-02-04 06:50:09 +00:00
Offline Capabilities
This commit is contained in:
26
functions/private/Test-WinUtilInternetConnection.ps1
Normal file
26
functions/private/Test-WinUtilInternetConnection.ps1
Normal file
@@ -0,0 +1,26 @@
|
||||
function Test-WinUtilInternetConnection {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Tests if the computer has internet connectivity
|
||||
.OUTPUTS
|
||||
Boolean - True if connected, False if offline
|
||||
#>
|
||||
try {
|
||||
# Test multiple reliable endpoints
|
||||
$testSites = @(
|
||||
"8.8.8.8", # Google DNS
|
||||
"1.1.1.1", # Cloudflare DNS
|
||||
"208.67.222.222" # OpenDNS
|
||||
)
|
||||
|
||||
foreach ($site in $testSites) {
|
||||
if (Test-Connection -ComputerName $site -Count 1 -Quiet -TimeoutSeconds 3 -ErrorAction SilentlyContinue) {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
return $false
|
||||
}
|
||||
catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user