SCCM如何在此代码中添加计算机名称?

时间:2019-10-04 06:07:47

标签: sql sccm

代码的目的;列出系统中心中计算机上的病毒/威胁。但是我无法在此代码中添加计算机名称。它不会起作用。我们应该怎么做?

Select distinct 

t.DetectionID,
t.DetectionTime,
IsNULL(tc.Name,t.ThreatName) as ThreatName, 
cat.Category,
sev.Severity,
t.PendingActions,
t.Process,
t.UserName,
t.Path,
t.CleaningAction,
t.ActionSuccess,
t.DetectionSource

from fn_rbac_R_System(@UserSIDs)  s 
join fn_rbac_GS_Threats(@UserSIDs)  t on s.ResourceID=t.ResourceID
left join fn_rbac_ThreatCatalog(@UserSIDs)  tc on t.ThreatID=tc.ThreatID
left join fn_rbac_ThreatSeverities(@UserSIDs)  sev on tc.SeverityID=sev.SeverityID 
left join fn_rbac_ThreatCategories(@UserSIDs)  cat on tc.CategoryID=cat.CategoryID

where t.DetectionID <> 'Null'

order by t.DetectionTime DESC

1 个答案:

答案 0 :(得分:1)

与函数fn_rbac_R_System(和基础视图v_R_System)中的fn_rbac_GS_Threats相比,大多数列都以尾随0命名,因此您要查找的属性是fn_rbac_R_System中的Name0。 (我认为这是因为通常这些视图由不同的数据源组成,并且为了防止多个具有相同名称的列,即使在名称已经是唯一的情况下,也总是对名称进行索引)。

因此在您的示例中,它必须是:

Select distinct 

s.Name0,
t.DetectionID,
t.DetectionTime,
IsNULL(tc.Name,t.ThreatName) as ThreatName, 
cat.Category,
sev.Severity,
t.PendingActions,
t.Process,
t.UserName,
t.Path,
t.CleaningAction,
t.ActionSuccess,
t.DetectionSource

from fn_rbac_R_System(@UserSIDs)  s 
join fn_rbac_GS_Threats(@UserSIDs)  t on s.ResourceID=t.ResourceID
left join fn_rbac_ThreatCatalog(@UserSIDs)  tc on t.ThreatID=tc.ThreatID
left join fn_rbac_ThreatSeverities(@UserSIDs)  sev on tc.SeverityID=sev.SeverityID 
left join fn_rbac_ThreatCategories(@UserSIDs)  cat on tc.CategoryID=cat.CategoryID

where t.DetectionID <> 'Null'

order by t.DetectionTime DESC