From c483cbf6872944a546d333635e53c81a747069e7 Mon Sep 17 00:00:00 2001 From: camoy Date: Thu, 15 Aug 2024 20:06:14 -0700 Subject: [PATCH] Wow I did an array --- scripts/ps/netcheck.ps1 | 49 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/scripts/ps/netcheck.ps1 b/scripts/ps/netcheck.ps1 index e07c654..2391dd7 100644 --- a/scripts/ps/netcheck.ps1 +++ b/scripts/ps/netcheck.ps1 @@ -18,22 +18,39 @@ fDefaultGatewayCheck } else { - Function fDNSResolutionCheck() { - Write-Host "---Testing DNS Resolution---" - Resolve-DnsName -Name "git.sdf.org" - $vSCDNSResolutionTestResult1 = $? - Resolve-DnsName -Name "customresolutionutility.b-cdn.net" - $vSCDNSResolutionTestResult2 = $? - Resolve-DnsName -Name "github.com" - $vSCDNSResolutionTestResult3 = $? - Resolve-DnsName -Name "www.ultimarc.com" - $vSCDNSResolutionTestResult4 = $? - Resolve-DnsName -Name "www.autohotkey.com" - $vSCDNSResolutionTestResult5 = $? - Resolve-DnsName -Name "eternallybored.org" - $vSCDNSResolutionTestResult6 = $? - Resolve-DnsName -Name "7-zip.org" - $vSCDNSResolutionTestResult7 = $? + fDNSResolutionCheck + } + } + else + { + Function fDNSResolutionCheck() { + Write-Host "---Testing DNS Resolution---" + Resolve-DnsName -Name "git.sdf.org" + $vSCDNSResolutionTestResult1 = $? + Resolve-DnsName -Name "customresolutionutility.b-cdn.net" + $vSCDNSResolutionTestResult2 = $? + Resolve-DnsName -Name "github.com" + $vSCDNSResolutionTestResult3 = $? + Resolve-DnsName -Name "www.ultimarc.com" + $vSCDNSResolutionTestResult4 = $? + Resolve-DnsName -Name "www.autohotkey.com" + $vSCDNSResolutionTestResult5 = $? + Resolve-DnsName -Name "eternallybored.org" + $vSCDNSResolutionTestResult6 = $? + Resolve-DnsName -Name "7-zip.org" + $vSCDNSResolutionTestResult7 = $? + $vSCDNSResolutionTestResultArray = @($vSCDNSResolutionTestResult1,$vSCDNSResolutionTestResult2,$vSCDNSResolutionTestResult3,$vSCDNSResolutionTestResult4,$vSCDNSResolutionTestResult5,$vSCDNSResolutionTestResult6,$vSCDNSResolutionTestResult7) + if ($vSCDNSResolutionTestResultArray -contains $false) + { + Write-Host "SC-NET-ERR002: CANNOT RESOLVE DNS" + Write-Host "Please check your DNS server. Sweetcade cannot continue with a broken DNS server." + Write-Host "This script will now exit in 60 seconds." + Start-Sleep -Seconds 60 + Exit 1 + } + else + { + Exit 0 } } }