diff --git a/scripts/ps/netcheck.ps1 b/scripts/ps/netcheck.ps1 index 2391dd7..29adc06 100644 --- a/scripts/ps/netcheck.ps1 +++ b/scripts/ps/netcheck.ps1 @@ -3,54 +3,54 @@ Function fDefaultGatewayCheck() { Get-WmiObject -Class Win32_IP4RouteTable | where { $_.destination -eq '0.0.0.0' -and $_.mask -eq '0.0.0.0' } | Sort-Object nexthop, metric1, interfaceindex $vSCNextHop = (Get-WmiObject -Class Win32_IP4RouteTable | where { $_.destination -eq '0.0.0.0' -and $_.mask -eq '0.0.0.0' } | Sort-Object metric1 | select nexthop | Format-Wide | Out-String).trim() Test-Connection $vSCNextHop + $vSCNextHopResult = $? } + fDefaultGatewayCheck - if ($? -eq $false) - { - Write-Host "SC-NET-ERR001: CANNOT PING DEFAULT GATEWAY" - Write-Host "Please check network connection" - Write-Host "If you would like to [F]orcefully continue, connect a keyboard and type F" - Write-Host "If you would like to run this test [A]gain, connect a keyboard and type A" - $vSCNextHopUserResponse = Read-Host "F / A?" - if ($vSCNextHopUserResponse -contains "A") - { - fDefaultGatewayCheck - } - else - { - 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) +} + +fDNSResolutionCheck + +if ($vSCNextHopResult -contains $false) + { + Write-Host "SC-NET-ERR001: CANNOT PING DEFAULT GATEWAY" + Write-Host "Please check network connection" + Write-Host "If you would like to [F]orcefully continue, connect a keyboard and type F" + Write-Host "If you would like to run this test [A]gain, connect a keyboard and type A" + $vSCNextHopUserResponse = Read-Host "F / A?" + if ($vSCNextHopUserResponse -contains "A") { - 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 - } - } + fDefaultGatewayCheck } + } + +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 + } \ No newline at end of file