命令/Powershell脚本重置网络适配器 [英] Command/Powershell script to reset a network adapter
问题描述
操作系统:Vista企业版
OS: Vista enterprise
当我在家庭和办公室网络之间切换时,我总是会遇到连接网络的问题.几乎总是需要在网络和共享中心"中使用诊断服务,使用重置网络适配器选项时,问题就可以解决.
When i switch between my home and office network, i always face issues with getting connected to the network. Almost always I have to use the diagnostic service in 'Network and sharing center' and the problem gets solved when i use the reset network adapter option.
这需要很多时间(3-4分钟),所以我试图找到一个命令或Powershell脚本/cmdlet,我可以直接使用它们来重置网络适配器并每次我自己保存这5分钟必须在网络之间切换.有指针吗?
This takes a lot of time (3-4 min) and so i was trying to find either a command or a powershell script/cmdlet which i can use directly to reset the network adapter and save myself these 5 mins every time i have to switch between the networks. Any pointers?
推荐答案
您可以在PowerShell中使用WMI来完成此任务.假设其中一个设备名称中包含 Wireless 的网络适配器,则一系列命令可能类似于以下内容:
You can use WMI from within PowerShell to accomplish this. Assuming there is a network adapter who's device name has Wireless in it, the series of commands might look something like the following:
$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
$adaptor.Enable()
请记住,如果要在Window的Vista中运行此程序,则可能需要以管理员身份运行PowerShell .
Remember, if you're running this with Window's Vista, you may need to run the PowerShell as Administrator.
这篇关于命令/Powershell脚本重置网络适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!