Collecting SCCM computer object last logon time.

Sometimes it may be usefull to see when the last time computer account contacted domain, so you could see which records are old and long time gone.

First you need to add an attribute to AD discovery.

Go to site management, open your site, Site Settings, Discovery Methods, open Active Directory System Discovery

Go to Active Directory Attribute

Click yellow start, and add "lastLogon"

Kick off Active Directory System Discovery

After it's collected, you can run a query like this:

 

 

 

select

DATEADD(hh, cast((LastLogon0 / (600000000))/ 60 as bigint), cast('1601-1-1' as datetime2) ) as  LastLogonDay,  * from v_R_System

order

by LastLogonDay desc

So, you can see which computers just logged on to domain, but don't have client installed, for instance.