This post is about a situation where I was not able to remove a logical switch from System Center Virtual Machine Manager 2012 R2 (with Update Rollup 1). This scenario might affect other versions. And the fix might not work for everyone.
I was removing a bunch of logical network stuff from VMM, just mucking around with different types of builds to find one that suited my needs in the lab. I came to delete the virtual switch (logical switch) from Fabric in the SCVMM console but it failed to go. The reason given was that there was a remaining dependency. I checked the dependencies but none were listed.
Very strange!
I tried everything I could think of. Then I gave my MVP friend Damian Flynn a shout to see if he’d seen it. He had (if Damian hasn’t seen it, then it doesn’t exist in VMM), but wasn’t able to remember exactly what the fix was. I suspected I’d be using PowerShell. Damian confirmed it. So we went “wandering” in SCVMM. I found a remaining VM Network. There is no inter-dependency with it and the logical switch, but I decided to delete it. And it wouldn’t delete because a physical computer network adapter was depending on it.
That was strange – I had no hosts or physical computer hardware profiles left ,,, apparently. Time for PowerShell. Finding the verb-noun combination was easy. Damian filled in the –all for me. The following cmdlet corrected me.
Get-SCPhysicalComputerNetworkAdapterProfile -all
Interesting.
I tried but it failed.
Get-SCPhysicalComputerNetworkAdapterProfile -all |Remove-SCPhysicalComputerNetworkAdapterProfile
Apparently a virtual network adapter depended on these physical NICs. Ah… now I knew what was wrong. More on that later.
The next cmdlet confirmed my theory:
Get-SCVirtualNetworkAdapter –all
I removed that virtual network adapter with:
Get-SCVirtualNetworkAdapter -all | Remove-SCVirtualNetworkAdapter
Now I was able to run the following:
Get-SCPhysicalComputerNetworkAdapterProfile -all |Remove-SCPhysicalComputerNetworkAdapterProfile
Then I was able to remove both the virtual network and the logical switch.
So what happened? My previously deleted physical computer hardware profile featured two physical NICs (with CDN defined – don’t know if that’s important for this situation). Those two NICs were teamed using a logical switch and uplink port profile, and a virtual management adapter was connected to the logical switch. That’s what my queries revealed: a virtual network adapter (the virtual management NIC) and physical network adapters. Both the VM Network and the logical switch were dependent on these resources.
It appears that the process to delete the physical computer hardware profile left behind the physical NICs and the virtual management adapter, and the GUI didn’t have a way to present those stragglers.
Thanks to Damian for his help … it proved to be a fine opportunity to run through my design with him. Doing Hyper-V networking via SCVMM is quite different to the much more flexible native WS2012 R2 PowerShell option.