A stale VM switch in Hyper-V is no longer used and when I try to delete it, it always fails with the following message:
PS C:\> Get-VMSwitch nat
Name SwitchType NetAdapterInterfaceDescription
---- ---------- ------------------------------
nat Private
PS C:\> Get-VMSwitch nat | Remove-VMSwitch -Force
Remove-VMSwitch : Failed while removing virtual Ethernet switch.
Switch delete failed, switch = 'acf82f05-c07c-4b35-8588-921498456027': General access denied error (0x80070005).
At line:1 char:20
+ Get-VMSwitch nat | Remove-VMSwitch -Force
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [Remove-VMSwitch], VirtualizationException
+ FullyQualifiedErrorId : AccessDenied,Microsoft.HyperV.PowerShell.Commands.RemoveVMSwitch
Attempting to delete within the GUI does not work, either:
I didn't want to install the Azure Powershell tools so I just followed the steps in this video: https://www.youtube.com/watch?v=V5Gb342gSGg
Basically you go to Network Connections -> open properties for the virtual switch you want to delete -> click Configure -> go to the Driver tab -> Uninstall Device.
To prevent the Hyper-V service from creating a new one next time I restart my computer without disabling it altogether I changed the Startup Type of each Hyper-V service to be Manual.
A similar problem was resolved on Microsoft's TechNet forums:
We have a virtual switch setup in the Virtual Switch Manager and the adapter has been deleted by mistake using the "Change Adapter Settings..." of the Network And Sharing Center. Now, obviously the switch is in a failed state and we just want to remove it from the list.
Ultimately, the OP performed an in-depth search within the registry and found the virtual switch configuration stored within the following key:
HKLM\SYSTEM\CurrentControlSet\Services\VMSMP\Parameters\SwitchList
After they deleted the corresponding value within that key and rebooted, the virtual switch was gone.
As always, I would recommend that you export your current settings to a .reg
file to have an appropriate backup before attempting similar changes.
(Source: Can't remove failed virtual switch from Hyper-V's Virtual Switch Manager)
Even though I'm not using Docker, I wanted to figure out a solution without using regedit
, so after attempting the answer from RobV8R, I found instructions on this question on MS Technet.
Get-HNSNetwork | Remove-HNSNetwork
Or, for a more filtered optoin, this is what I needed.
Get-HNSNetwork | ? Name -Like "Default Switch" | Remove-HNSNetwork
Also, I'm going to assume that you'll want to follow @mxgg250's advice, and set all hyper-v services to manual start, otherwise it's going to recreate the switch on reboot.
BEGIN EDIT
Newer versions of Windows 10 introduced a "Default Network" virtual switch.
If this method doesn't work for, Please see the response from @bradlis7 for another option.
END EDIT
This was tested on Windows 10 1607.
Short Answer, if you're using Docker:
PS> Stop-Service com.docker.service
PS> Remove-ContainerNetwork -Name nat
Long Answer:
If you run into this situation and have Containers enabled or Docker installed, you'll need to stop Docker before you can remove the VMSwitch.
PS> Get-VMSwitch
Name SwitchType NetAdapterInterfaceDescription
---- ---------- ------------------------------
DockerNAT Internal
nat Internal
Windows Phone Emulator Internal Switch Private
Primary Virtual Switch External Intel(R) Wireless
As you can see, I have a VMSwitch named nat
. I want it to go away.
PS> Remove-VMSwitch -Name nat
Confirm
Are you sure you want to remove the virtual switch "nat"?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Remove-VMSwitch : Failed while removing virtual Ethernet switch.
Switch delete failed, switch = '<guid>': General access denied error (0x80070005).
At line:1 char:1
+ Remove-VMSwitch -Name nat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [Remove-VMSwitch], VirtualizationException
+ FullyQualifiedErrorId : AccessDenied,Microsoft.HyperV.PowerShell.Commands.RemoveVMSwitch
The answer turned out to be rather simple. Because I had configured the nat
VMSwitch with a NetNat, I removed the NetNat. I'm unsure if this is a necessary step, but I did it anyway.
PS> Get-NetNat -Name '<name>' | Remove-NetNat
Then I stopped Docker.
PS> Stop-Service com.docker.service
And finally
PS> Remove-ContainerNetwork -Name nat
Confirm
Remove-ContainerNetwork will remove the container network "nat".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
To make sure it was gone:
PS> Get-VMSwitch
Name SwitchType NetAdapterInterfaceDescription
---- ---------- ------------------------------
DockerNAT Internal
Windows Phone Emulator Internal Switch Private
Primary Virtual Switch External Intel(R) Wireless
I am not sure if this is right but worked for me: https://www.online-tech-tips.com/computer-tips/unable-delete-network-adapter-windows-10/
The first thing you can try to do is open Device Manager (click on start and type device manager), expand Network Adapters, and then right-click on the network adapter you want to remove.
Here, you will see an option called Uninstall device. This should hopefully not be greyed out. If it is, continue to the next method. When you select uninstall device, another window will appear asking to confirm the uninstall.
You’ll also see an option to delete the driver software for the device. If you want to completely remove the network adapter, I suggest selecting this option to remove the driver also. If all goes well, you should see that the adapter has been removed from both Device Manager and the list of network adapters in Control Panel.
If you don’t see the device listed here, you can try to click on View and then Show hidden devices.
We can also try to delete the network profile via the command line and then try Method 1 again. First, you have to open an elevated command prompt by clicking on Start, typing in CMD and then right-clicking on command prompt and choosing Run as Administrator.
Now type in the following command to see all wired (Ethernet) adapters:
netsh lan show profiles
If you need to remove a wireless adapter, type this command:
netsh wlan show profiles
If you get some error message about the Wired or WLAN AutoConfig service not running, then click on Start, type in services.msc, right-click on the appropriate service and choose Start.
Now when you run the command, you should see a list of profiles. In my case, I only have one profile on this computer.
Next, type in the following command, which will delete the desired interface.
netsh lan delete profile interface="InterfaceName"
Again, if it’s a wireless interface, use wlan instead of lan. The interface name is listed at the top of each heading (Profile on interface name) when you ran the show profiles command. Once the profile has been deleted, restart your computer and try Method 1 again.
IMPORTANT
If you need to edit the registry, make sure you backup the registry first.
In addition to deleting the network profile, you can also try to remove the adapter settings via the registry. After you remove the settings, you can go back to method 1 and try to remove the adapter. To remove the settings, open the registry editor (click on Start and type in regedit.msc), and navigate to the following key:
HKEY_LOCAL_MACHINE - SYSTEM - CurrentControlSet - Services - Tcpip - Parameters - Interfaces
You’ll see several items listed with a long series of random numbers. If you click on each one, you’ll see the IP address that is assigned to that network adapter.
You can confirm which network adapter corresponds to that registry key by opening a command prompt (Start and type cmd) and typing in ipconfig.
As you can see, Ethernet adapter is the one that has an IP address of 192.168.1.233. So you would delete the key under Interfaces that starts with {73123f2a-ad10-4f4b-900e…}. If you click on a different interface, one of them will have the IP 192.168.247.1, which corresponds to the VMWare Network Adapter on the computer. Again, this only deletes the settings for the adapter, not the adapter itself. Restart the computer and try Method 1 again.
For further information please referto the following link:
https://www.online-tech-tips.com/computer-tips/unable-delete-network-adapter-windows-10/
Before trying the solutions above, make sure to check the 'details' pane for the error message. In my case, it read that the failure occurred due to other VMs still using the switch.
Turning the VMs off and trying again, did remove the switch.
Well, I spent a day trying to figure out what's wrong with it. I had slow internet after some moment - I event did not touch anything related to internet connections.
As you can see you just need to uncheck Hyper-V config in your standard internet connection by default. That's it - after that I got it working.
It may look that it is not an answer but it really can help people like me.
There is a simpler way to fix the problem on Microsoft's TechNet forums:
Try Deleting the Bridge Adapter from "Control Panel > Network and Internet > Network Connections"
User contributions licensed under CC BY-SA 3.0