-- DROP TEMP TABLE if for some reason it already exists IF OBJECT_ID('tempdb..#Temp_FCSReg') IS NOT NULL DROP TABLE #Temp_FCSReg -- CREATE TEMP TABLE Create table #Temp_FCSReg ( [ID] int not null, [Name] varchar(255) not null, [FCSHomeServer] varchar(255) null, [AVDisabled] int null, [SPYDisabled] int null ) -- Initialise Table INSERT INTO #Temp_FCSReg (ID, Name) SELECT ResourceID, Netbios_Name0 from v_R_System -- Add FCS Home server UPDATE #Temp_FCSReg SET #Temp_FCSReg.FCSHomeServer = string0 FROM v_GS_Registry_Values0 WHERE keyname0 = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Microsoft Forefront\Client Security\1.0|MOMServerName' and string0 is not null and ID = ResourceID UPDATE #Temp_FCSReg SET #Temp_FCSReg.AVDisabled = integer0 FROM v_GS_Registry_Values0 WHERE ( keyname0 = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Microsoft Forefront\Client Security\1.0\AM|DisableAntiVirus' or keyname0 = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Microsoft Forefront\Client Security\1.0|DisableAntiVirus' ) and integer0 is not null and ID = ResourceID UPDATE #Temp_FCSReg SET #Temp_FCSReg.SPYDisabled = integer0 FROM v_GS_Registry_Values0 WHERE ( keyname0 = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Microsoft Forefront\Client Security\1.0\AM|DisableAntiSpyware' or keyname0 = 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Microsoft Forefront\Client Security\1.0|DisableAntiSpyware' ) and integer0 is not null and ID = ResourceID -- Delete Empty Records DELETE FROM #Temp_FCSReg WHERE FCSHomeServer is null and AVDisabled is null and SPYDisabled is null -- DISPLAY RECORDS SELECT Name as [System Name], FCSHomeServer as [FCS Home Server], CASE AVdisabled WHEN 0 THEN 'Yes' ELSE 'No' END AS [Is AV Running?], CASE SPYDisabled WHEN 0 THEN 'Yes' ELSE 'No' END AS [Is Anti-Spy Running?] FROM #Temp_FCSReg ORDER BY Name DROP TABLE #Temp_FCSReg