Hello Garth,
Below is the query:
select distinct
SYS.Name0 As [Computer],
SYS.AD_Site_Name0 As [Site],
((sys.User_Domain0 + '\' + sys.User_Name0)) AS [user],
(SELECT CONVERT(CHAR(11),gs.LastHWScan,103) + CONVERT(CHAR( 5),gs.LastHWScan,114)) as [Heartbeat],
' ' as [Logon Count],
(SELECT TOP 1 IPAddress0
FROM v_GS_NETWORK_ADAPTER_CONFIGUR as NetCard
WHERE NetCard.resourceID = sys.resourceID
AND NetCard.IPAddress0 NOT like 'NULL'
AND DefaultIPGateway0 !=' '
) as [Ip Addr],
(SELECT Top 1 IPSubnet0
FROM v_GS_NETWORK_ADAPTER_CONFIGUR as NetCard
WHERE NetCard.resourceID = sys.resourceID
AND NetCard.IPAddress0 NOT like 'NULL'
AND DefaultIPGateway0 !=' '
) as [Ip Subnet],
' ' as [IP Count],
(SELECT CONVERT(CHAR(11),ls.TimeStamp,103) + CONVERT(CHAR( 5),ls.TimeStamp,114)) as 'Last Logon',
ls.UserName0 As 'Last Logged on User'
from
v_R_System SYS
join v_FullCollectionMembership FCM on SYS.ResourceID = FCM.ResourceID
join v_Collection COL on FCM.CollectionID = COL.CollectionID
join v_GS_WORKSTATION_STATUS gs on SYS.ResourceID = gs.ResourceID
Left Outer join v_GS_NETWORK_ADAPTER_CONFIGUR ip on sys.ResourceID=ip.ResourceID
join v_GS_Computer_System ls on ls.ResourceID=sys.ResourceID
where
COL.Name = 'All Systems'
and (DateDiff(DAY,gs.LastHWScan, GetDate()) < 1)
and (sys.Client0 not like '%0%'
and sys.Operating_System_Name_and0 like '%NT_Workstation%'
and sys.User_Name0 not like 'NULL'
and ip.IPAddress0 Not like '0.0.0.0'
)
Order By [Computer]
Point to be noted is there are more than 25 k systems in the nevironment but only 200 systems are not returning their 'LAst Logon User' data :|
Regards
-
Edited by
DEEP DAS
Tuesday, June 23, 2015 1:12 PM