
这个帖子的后续:t/847384。起因是昨天发现网络协商的速度只有 100Mbps 了,重新插网线才解决。
评论区很多热心网友提供了建议,但我还是不能确定是网线、接口本身的问题还是没插好导致的,所以我需要观察一段时间。
那么问题来了,100Mbps 其实也能正常上网、看视频等,很有可能降速了我第一时间发现不了。
于是我用自己拙劣的 Powershell 基础写了个小脚本用来检查当前网速是 Gbps 还是 Mbps:
Import-Module BurntToast $speed = Get-NetAdapter -Name Ethernet | Format-Wide -Property linkSpeed | Out-String $speed = $speed -replace '(^\s+|\s+$)','' if ($speed -Like '*Gbps*') { Write-Output 'info: check normally' } elseif ($speed -Like '*Mbps*') { $info = 'warning: network speed has been downgraded to ' + $speed Write-Output $info New-BurntToastNotification -Text $info } else { Write-Output 'error: failed to get network speed' } 里面用了这个模块https://github.com/Windos/BurntToast,如果发现 Ethernet 的网速变成 Mbps ,就发一个通知。
然后这个脚本需要让它定时运行,所以我加了个计划任务。
Security Options 设置成系统级,这样运行的时候不会有蓝色 Powershell 窗口弹出:

Trigger 增加一个 daily 任务,然后 repeat 改成 1 hour ,一小时运行一次:

Actions 增加 Powershell 运行的命令,别忘了加-ExecutionPolicy RemoteSigned:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy RemoteSigned -File check-speed.ps1 
最后 Conditions 设置成联网后,或者连特定的网络时才会检查:

如果检查出问题,右下角就会弹出一个 Notification:

后面就静待了,看看还会不会出现降速的问题~希望脚本没写出 Bug
1 oy9r 2022-04-17 19:19:49 +08:00 可以可以 |
2 AlphaTauriHonda 2022-04-17 19:25:54 +08:00 Wi-Fi 可以有类似的检测工具吗? |
3 jousca 2022-04-17 19:31:18 +08:00 必须支持一下。 |
4 phithon OP @AlphaTauriHonda 可以的,改下 Get-NetAdapter 的 Name |
5 hxsf 2022-04-17 21:49:52 +08:00 关掉自动协商,强制 1G ,不能 1G 的话,网络就会断开。 |
7 mortal 2022-04-18 07:36:44 +08:00 via iPhone 谢谢,家里 2.5G 有时候也降,改吧改吧用 |
8 AlphaTauriHonda 2022-04-18 08:42:56 +08:00 @mortal 要开始考虑提升线材质量了。 |
9 sbabybird 2022-04-18 14:36:11 +08:00 厉害厉害,经过你的提醒我发现我家的也是这样,不过我是路由器到光猫的网线总是协商成 100M 的,网线是装修时预埋的,水晶头是我后来自己掐的,看来只能定时重启路由了。 |
11 RoyLaw 2022-04-19 11:02:53 +08:00 重新做个水晶头啊 |