Video Screencast Help
Search Video Help Close Back
to help
Not able to make it to Vision this year? Get a sampling in the Best of Vision on Demand group.

What is the SQL code to check the last time a PC was logged on?

Updated: 21 May 2010 | 3 comments
yusgab's picture
0 0 Votes
Login to vote

Our company is looking for little used or non used PCs to recover from our user depts who claim they need the PCs. I am looking for some way to print out a list of PCs that have not been logged on to in the past 30 days....any help would be appreciated...I know some SQL and DB tables in Altiris....thanks.

Comments

Richard Taylor's picture
06
Nov
2008
0 Votes 0
Login to vote

yusgab, following code might help. You'll need to put in a SQL datediff for the 30 day thing too.

---------

Select vc.[name], eulu.[last logon] from vComputer vc

INNER JOIN inv_aex_eu_logon_users eulu on vc.guid = eulu._resourceguid where vc.guid in

(SELECT TOP 10 [_resourceguid]

FROM [Altiris].[dbo].[Inv_AeX_EU_Logon_Users]

order by [last logon])

-----



thanks

r

sandy peter's picture
16
Nov
2008
0 Votes 0
Login to vote

find your answers from google

KSchroeder's picture
17
Nov
2008
0 Votes 0
Login to vote

Sandy,

If you're not going to post anything helpful, please keep you comments to yourself.



Yusgab/Ricodjs:

I think the following code should give you what you're looking for:

quote:
Select vc.[name], eulu.[User], eulu.[Last Logon] AS [Last Logon]

from vComputer vc

JOIN inv_aex_eu_logon_users eulu

on vc.guid = eulu._resourceguid

AND UPPER(vc.[User]) = UPPER(eulu.[User])

WHERE eulu.[User] IS NOT NULL

AND eulu.[User] <> ''

GROUP BY vc.Name, eulu.[User], eulu.[Last Logon]

HAVING DATEDIFF(dd, max(eulu.[Last Logon]), GETDATE()) > 30

ORDER By max(eulu.[Last Logon]) DESC

What is your goal here though? Are you trying to find computers which no one has logged on to, or computers that are no longer connected to the network? If you're looking for "offline" computers, there are better built-in reports (specifically the "Clients with No Configuration in N Days" report on Reports > NS Infrastructure > Agent > Configuration Request folder.

Thanks,
Kyle
Symantec Trusted Advisor

For Forum threads, please click "Mark as Solution" if answered.
For all content, please give a thumbs up if you agree with or support the post.