Restart Ethernet Adapter using PowerShell on Windows

In case you are having a problem with your Ethernet adapter, such as not connecting properly or obtaining an IP address when you insert the cable (happens with me sometimes in one of the networks I connect to), you can do the following:

Create a file named “restart_ethernet.ps1”, add the following content to it and save:

# Disable the network adapter
Disable-NetAdapter -Name "Ethernet" -Confirm:$false

# Wait for 5 seconds
Start-Sleep -Seconds 5

# Enable the network adapter
Enable-NetAdapter -Name "Ethernet"

Now, on your Desktop, right click, create a Shortcut and add the following content to the location section:

powershell.exe -ExecutionPolicy Bypass -File "C:\restart_ethernet.ps1"

Save it with a meaningful name such as Restart Ethernet or something. After you are done, just right click on it and choose “Run As Administrator”, and it’s done:

Enjoy!

Note: In case “Ethernet” doesn’t work with you, run Get-NetAdapter and it should list all the network adapters in your network and choose the correct one.

Unknown's avatar

About Ahmed Tawfik

Cybersecurity Professional, Systems Engineer, OSS & Linux Geek
This entry was posted in Windows and tagged , , . Bookmark the permalink.

Leave a comment