From 14b28939bba67cc0027017bbbae07a97d7dd7ede Mon Sep 17 00:00:00 2001 From: Christopher York Date: Mon, 30 Mar 2015 11:54:06 -0600 Subject: [PATCH] Fixed issue where deleting a virtual machine also deletes the assigned switch This can cause issues if more than 1 VM are assigned to the same virtual switch --- .../HyperV2012R2.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/HyperV2012R2.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/HyperV2012R2.cs index 7065e666..cbefbb16 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/HyperV2012R2.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Virtualization.HyperV-2012R2/HyperV2012R2.cs @@ -509,8 +509,10 @@ namespace WebsitePanel.Providers.Virtualization { NetworkAdapterHelper.Delete(PowerShell, vm.Name, networkAdapter); - if (!string.IsNullOrEmpty(networkAdapter.SwitchName)) - DeleteSwitch(networkAdapter.SwitchName); + // If more than 1 VM are assigned to the same switch, deleting the virtual machine also deletes the switch which takes other VM instances off line + // There may be a reason for this that I am not aware of? + //if (!string.IsNullOrEmpty(networkAdapter.SwitchName)) + //DeleteSwitch(networkAdapter.SwitchName); } Command cmdSet = new Command("Remove-VM");