# ========================================================= # MAX 网络工具箱 - 网络诊断 # Ping 检测 / DNS 解析 / 网卡信息 / DNS 服务器 # ========================================================= $Common = "C:\Setup\windows\lib\common.ps1" if (Test-Path $Common) { . $Common } Write-Header "网络诊断" # ========================================================= $Targets = @( "223.5.5.5", "119.29.29.29", "1.1.1.1", "8.8.8.8", "dl.unvmax.com", "www.baidu.com", "www.microsoft.com" ) try { Write-Section "Ping 连通性测试" foreach ($Target in $Targets) { try { Write-Info "测试: $Target" Test-Connection $Target -Count 2 -ErrorAction SilentlyContinue Write-OK "$Target 连通正常" } catch { Write-Warn "$Target 不可达" } Write-Host "" } Write-Line Write-Section "DNS 解析测试" $DnsTargets = @("dl.unvmax.com", "www.microsoft.com", "www.baidu.com") foreach ($Target in $DnsTargets) { try { Write-Info "解析: $Target" Resolve-DnsName $Target -ErrorAction SilentlyContinue | Select-Object -First 3 | Format-Table Name, IPAddress -AutoSize Write-OK "$Target 解析成功" } catch { Write-Warn "$Target 解析失败" } Write-Host "" } Write-Line Write-Section "网络适配器信息" try { Get-NetAdapter | Format-Table Name, Status, LinkSpeed, MacAddress -AutoSize } catch { Write-Err "获取网络适配器信息失败" Write-Muted $_.Exception.Message } Write-Line Write-Section "当前 DNS 服务器" try { Get-DnsClientServerAddress -AddressFamily IPv4 | Format-Table InterfaceAlias, ServerAddresses -AutoSize } catch { Write-Err "获取 DNS 服务器信息失败" Write-Muted $_.Exception.Message } Write-Line Write-OK "网络诊断完成" } catch { Write-Err "网络诊断过程中出现错误" Write-Muted $_.Exception.Message } Pause-Max