Possibly to query users based on login time/status?

3,538 views
Skip to first unread message

Steve O'Brien

unread,
Jan 31, 2017, 1:27:58 PM1/31/17
to GAM for G Suite
I have not been able to find a way to list users based on their lastlogintime or if they have never logged in.  Is it possible?

TIA,
Steve

Graham Ingleby

unread,
Feb 1, 2017, 10:35:40 AM2/1/17
to GAM group
Hi Steve

You can print all users, including their last login time, send it to a sheet and then sort that sheet - I think a user who has never logged in shows a date like 01/01/1970 rather than being blank. Also note the last login time is the last time the user went through the login process in the browser, not the last time they opened the browser (with sign in cached it is still signed in, not a new sign in) or used a mobile app/POP/IMAP.

From the wiki page https://github.com/jay0lee/GAM/wiki/GAM3CSVListings#printing-all-users something like this would get you the information (assuming you want first and last names as well as their email address):

gam print users firstname lastname lastlogintime todrive

Graham



This message is for the named person's use only. If you receive this message in error, please delete it and notify the sender. Ancoris reserves the right to monitor all e-mail communications through its networks. Ancoris Limited, Registered in England Number: 04830784, Registered address: 5a Frascati Way, Maidenhead, Berkshire SL6 4UY. Trading Address: Lily Hill House, Lily Hill Road, Bracknell, Berkshire RG12 2SJ




David Tod

unread,
Feb 1, 2017, 2:37:37 PM2/1/17
to GAM for G Suite
You can do a Report using query parameters, e.g. here's one I recently did:

gam report users filter "accounts:last_login_time==1970-01-01T00:00:00.000Z,accounts:last_sso_time==1970-01-01T00:00:00.000Z,accounts:creation_time<2017-02-01" fields 'accounts:creation_time,accounts:last_login_time,accounts:last_sso_time'

The 1970 dates are for those that have never logged in and in this case I was interested in those created more than a year ago. Here (https://developers.google.com/admin-sdk/reports/v1/reference/usage-ref-appendix-a/users-accounts) are all the users query parameters which are prefixed with "accounts:" - a docs parameter might be something like "docs:num_docs>5" (see https://developers.google.com/admin-sdk/reports/v1/reference/usage-ref-appendix-a/users-docs).

I seem to recall if that if you leave off the fields part, you'll get all the possible query-able fields. The GAM docs are here: https://github.com/jay0lee/GAM/wiki/GAM3CSVListings#users-report

HTH

David

+KimNilsson

unread,
Feb 6, 2017, 8:55:09 AM2/6/17
to GAM for G Suite
Hmm, when I last checked lastlogintime for a new user I seem to remember it saying "Never" and not 1970.

Jay Lee

unread,
Feb 6, 2017, 9:00:30 AM2/6/17
to GAM for G Suite
GAM will sometime replace 1/1/1970 with never since it's less confusing but can't do so in all cases.

Jay

On Mon, Feb 6, 2017 at 8:55 AM +KimNilsson <there.is.no...@gmail.com> wrote:
Hmm, when I last checked lastlogintime for a new user I seem to remember it saying "Never" and not 1970.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/f6a00bc6-9d73-41c3-bbc3-2f48bc46ef36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Jay

Reply all
Reply to author
Forward
0 new messages