Categories
How-To Technical

Tech-Short: Delete Virtual Switch in Hyper-V

And this happened . . .

I was introducing a change the Virtual Switch Manager of my Hyper-V host, where I attempted to give guest machines bridged network access.  After making my change I had lost access to the server.  On a good note, the server picked up a new address its virtual interface that I created.  However I am unable to connect to the Hyper-V services so I am taking steps to delete the interface and review my steps.

To do this I first attempted the following things:

Issued the command: Get-VMSwitch to list the name of the network adapter interface. I then attempted to remove the interface by entering:

Get-VMSwitch | Remove-VMSwitch

After being prompted and selecting Y for “Yes” I was given an error:

Remove-VMSwitch : Failed while removing virtual Ethernet switch.
The virtual switch ‘Default VLAN’ cannot be deleted because it is being used
by running virtual machines or assigned to child pools.
The operation cannot be performed while the object is in use.
At line:1 char:16
+ Get-VMSwitch | Remove-VMSwitch
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceBusy: (Microsoft.HyperV.PowerShell.VMTas
k:VMTask) [Remove-VMSwitch], VirtualizationOperationFailedException
+ FullyQualifiedErrorId : ObjectInUse,Microsoft.HyperV.PowerShell.Commands
.RemoveVMSwitchCommand

This error was thrown because of the virtual machine(s) I have running so I needed stop it (or them).

A quick issue of the command Get-VM to return the full name of the VM running in this lab followed by a quick issue of:

Get-VM | Stop-VM

One all VM guests are off I was able to reissue the command Get-VMSwitch | Remove-VMSwitch at which point the previous IP became active again. A quick restart of the Hyper-V Server host and I was once again able to connect.

Now its time to learn what I did incorrectly to cause this issue.

One reply on “Tech-Short: Delete Virtual Switch in Hyper-V”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.