Last Logon Time for last logged on Username

(imported topic written by SystemAdmin)

I searched and could not find existing thread that will answer this specific question. I do have (as a default property) the last logon name for each of the computer in my environment (close to 6000 machines) that are joined to the domain. I tried this to get last logon but results with “multiple results”. Can anyone help me modify this so I only get result for username for same record in same row?

string values of selects “LastLogon from Win32_NetworkLoginProfile” of wmi

Thanks.

(imported comment written by SystemAdmin)

I’ve used this in the past, but not sure whether this suits what you’re trying to do (or solves the problem).

value “DefaultUserName” of key “HKEY_LOCAL_MACHINE|Software\Microsoft\Windows NT\CurrentVersion\Winlogon” of registry as string

-Jim

(imported comment written by SystemAdmin)

Thank you Jim. Appreciate your response on this. Acutally I just re read my question and I forogt to type (unlik the subject), I am looking for the Last Logon Time for each username that is populated with each computer. When I tried the selects of wmi as stated above, I get multiple result set (its getting all user’s logon time). I just need to know how can this relevance be modified so I end up only with Last Logon Time of the user reported for same row.

Thanks.

(imported comment written by SystemAdmin)

Found this on the old forum and you can probably modify it to suit your needs(and much, much better than using wmi):

(names of it, logon count of it, password ages of it, last logons of it) of local users

-Jim

(imported comment written by SystemAdmin)

Thank you again Jim. The reason I used wmi option is that I did not see any relevance query method that will query all users regardless of being local or domain user. wmi gave me all user names for the domain logins what I needed.

This relevance also only queries the local users and not domain user what I am really looking for as my environment admins are just the IT team and we are querying for the business logons. Thank you.