Command/Powershell script to reset a network adapter

94,528

Solution 1

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()

Remember, if you're running this with Window's Vista, you may need to run the PowerShell as Administrator.

Solution 2

Zitrax's answer:

netsh interface set interface "InterfaceName" DISABLED
netsh interface set interface "InterfaceName" ENABLED

was 99% of what I was looking for. The one piece of information that s/he left out, though, was that these commands have to be run as an administrator. Either run cmd.exe as an admin and type them in, or store them in a batch file, and then run that file as admin by right clicking on it and choosing "Run as Administrator" from the context menu.

Solution 3

See this article from The Scripting Guys, "How Can I Enable or Disable My Network Adapter?"

tl/dr:

Restart-NetAdapter   -Name "Your Name Here"

You can get the list using

Get-NetAdapter

Solution 4

You can also try this in a .BAT or .CMD file:

ipconfig /release
ipconfig /renew
arp -d *
nbtstat -R
nbtstat -RR
ipconfig /flushdns
ipconfig /registerdns

These commands should do the same things as the 'Diagnose and Repair' for the network adapter, but is WAY faster!

Let me know if this helps! JFV

Solution 5

What worked for me:

netsh interface show interface

to show the interface name which for me was "Ethernet 2" and then:

netsh interface set interface "Ethernet 2" DISABLED
netsh interface set interface "Ethernet 2" ENABLED
Share:
94,528
Mohit
Author by

Mohit

Updated on July 18, 2022

Comments

  • Mohit
    Mohit almost 2 years

    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.

    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?