如何在 powershell 中检索 vista 的网络状态(例如“仅限本地”、“本地和互联网”)
我的网卡不稳定,有时会掉线,尤其是从休眠状态恢复后。退出对应于 Vista 的网络状态在通知区域中显示为“仅限本地”。有没有办法以编程方式检索这些状态值(例如“有限连接”、“仅限本地”、“本地和互联网”)?
我正在编写一个 powershell 脚本,用于轮询连接是否已关闭,如果是,则重置适配器。目前我正在尝试通过 ping 我的 ISP 的 DNS 服务器来检测连接状态。但是,由于操作系统已经正确识别了这种情况,因此如果我可以检索该值就会简单得多。
谢谢!
I have a flaky NIC that drops out from time to time, especially after resuming from hibernation. A drop-out corresponds to Vista's network status showing in the notification area as "Local Only". Is there a way of retrieving these status values (e.g. "Limited Connectivity", "Local Only", "Local and Internet") programmatically?
I am writing a powershell script that polls to see if the connection is down, and if so, resets the adapter. Currently I am trying to detect the connection state by pinging my ISP's DNS server. However, since the OS is already correctly identifying this condition, it would be much simpler if I could just retrieve this value.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这个函数:
如果将
$connections
和输出从GetNetwork()
传输到Get-Member
,您会发现一些更有用的方法。Try this function:
If you pipe
$connections
and output fromGetNetwork()
toGet-Member
you will find some more useful methods.