4fd81048-Brian / DirectRemove-SCVMHost

Script to manually remove an orphaned host or cluster from VMM
2 stars 2 forks source link

Leftover virtual network adapters #3

Open 4fd81048-Brian opened 3 years ago

4fd81048-Brian commented 3 years ago

Virtual network adapters are not cleaned up from [dbo].[tbl_WLC_VNetworkAdapter]

4fd81048-Brian commented 3 years ago

Potential fix committed to branch, but untested. I cleaned up my own DB identified by

select VNicID, [tbl_WLC_VNetworkAdapter].[HostId], [tbl_ADHC_Host].[HostID]
from [dbo].[tbl_WLC_VNetworkAdapter] left outer join [dbo].[tbl_ADHC_Host]
on [tbl_WLC_VNetworkAdapter].[HostId] = [tbl_ADHC_Host].[HostID]
where [tbl_ADHC_Host].[HostID] is null
and [tbl_WLC_VNetworkAdapter].[HostId] is not null
order by [tbl_WLC_VNetworkAdapter].[HostId]

with

select * 
-- delete
from [dbo].[tbl_WLC_VNetworkAdapter]
where [dbo].[tbl_WLC_VNetworkAdapter].[HostId]
 in (
  select [tbl_WLC_VNetworkAdapter].[HostId]
  from [dbo].[tbl_WLC_VNetworkAdapter] left outer join [dbo].[tbl_ADHC_Host]
  on [tbl_WLC_VNetworkAdapter].[HostId] = [tbl_ADHC_Host].[HostID]
  where [tbl_ADHC_Host].[HostID] is null
  and [tbl_WLC_VNetworkAdapter].[HostId] is not null
)