Skip to content

Can't delete VMSwitch after connecting with WSLAttach #10

@nrclark

Description

@nrclark

I can attach a VMSwitch to WSL using WSLAttachSwitch.exe, and everything works fine. But when I try to delete the VMSwitch afterwords, this operation fails. It fails if I do it using the Hyper-V Manager GUI, and also if I try to do it in Powershell.

Here's a Powershell script that demonstrates the failure:

New-VMSwitch -Name "Testbench VMSwitch" -NetAdapterName MyAdapter

#ensure that WSL is running
wsl.exe sleep 0

WSLAttachSwitch.exe "Testbench VMSwitch"
wsl.exe --shutdown
Start-Sleep -Seconds 10
Remove-VMSwitch "Testbench VMSwitch" -Force

Everything works fine until my call to Remove-VMSwitch. But when I run that, it hangs at 0% until I kill the operation. After I've killed the operation, my machine is in an error-state where I can't modify, overwrite, or remove the VMSwitch instance.

What can I do to kill a switch before trying to delete it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions