Sweetcade/scripts/ps/netcheck.ps1

48 lines
2.0 KiB
PowerShell

Write-Host "---Function Setup---"
function fSCGetDefaultGateway {
Write-Host "---Determine Default Gateway---"
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()
}
function fSCPingDefaultGateway {
Test-Connection $vSCNextHop
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 "F")
{
function fSCDNSResolutionTest
}
[else {
function fSCPingDefaultGateway
}]
}
}
function fSCDNSResolutionTest {
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 = $?
}
#PSEUDO - Check each hostname for name resolution, if-then to next script (syscheck.ps1)