PCs with the no logon information for 30 days

SELECT distinct
CS.Name0 AS ‘Computer’,
isnull(CS.UserName0,HCS.UserName0) AS ‘User Name’ ,
CS.TimeStamp
FROM
v_GS_COMPUTER_SYSTEM CS Left outer join v_HS_COMPUTER_SYSTEM HCS on CS.ResourceID = HCS.ResourceID
WHERE
HCS.UserName0 is not NULL
and datediff(dd,CS.TimeStamp,getdate()) > 30
Group by
CS.Name0,
CS.UserName0,
CS.TimeStamp,
HCS.UserName0
order by
CS.Name0

Leave a Reply

Your email address will not be published. Required fields are marked *