Delete User and Transfer File Ownership?

1,617 views
Skip to first unread message

Timothy Musa

unread,
Aug 10, 2017, 10:53:42 AM8/10/17
to GAM for G Suite
Hello,
I've found the command that will pull the list of suspended users and use that list to delete users. When we do this manually using the Admin Console we get the option to transfer Google Drive ownership for all shared documents / folders. Is this option available somehow using GAM? Or would I need to split it into the two tasks like so:

gam print users query "isSuspended=true" | gam user ~primaryEmail transfer drive arch...@example.com

gam print users query "isSuspended=true" | gam delete user ~primaryEmail


Doing this, will Google skip deleting the user until the file ownership transfer completes?

Also, when deleting through Admin Console the file transfer only transfers ownership of shared items (unless a box is checked). Is this an option with GAM? Or will it always transfer all files?

Thanks,
Tim

Timothy Musa

unread,
Aug 10, 2017, 1:17:33 PM8/10/17
to GAM for G Suite
For those interested, I think I finally figured it out.

gam print users query "isSuspended=true" | gam csv - gam create datatransfer ~primaryEmail gdrive arc...@example.com privacy_level shared

gam print users query "isSuspended=true" | gam csv - gam delete user ~primaryEmail

I tested out these two commands on my remaining 7 suspended accounts. It looks like everything worked the way it should.

Alex Korkishko

unread,
Aug 18, 2017, 12:41:34 PM8/18/17
to GAM for G Suite
Thank you for sharing the command. I am totally new to GAM, so digging through the forums for the answers. I am trying to do the same thing as you, except I just want to dump it into a csv file. Do you have any idea what command to do?

Also, looking for a way to delete suspended users who have been suspended for longer than a year. Any thoughts?

Thanks!
-Alex

Timothy Musa

unread,
Aug 18, 2017, 1:06:31 PM8/18/17
to GAM for G Suite
Well, 

The basic command of "gam print users query "isSuspended=true"" will output the suspended users in a CSV. Of course in this basic format the only column in the CSV is the primaryEmail of the suspended users. There are ways to add field to this output, but I don't recall off hand what they are.

As far as deleting suspended users after a period of time, I think I saw a response in a prior post that Google doesn't tag the suspension date anywhere, so you would be on your own to generate that information. The only way I can think to do it is to pull the list of suspended users and use some process to compare the new list to an existing list and tag any new entries with the current date. Though I don't have any thoughts on how to actually do this process of tagging the new entries.

Alex Korkishko

unread,
Aug 18, 2017, 1:09:57 PM8/18/17
to google-ap...@googlegroups.com
Thank you Timothy! Once I posted, I was able to export all my suspended users, now I am going to play with the lastlogintime variable to see if I can use that to help me find old accounts.


Alex Korkishko
Weber School District, Utah
Applications and Support Manager

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/d_oZtmQCTWE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@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/db62c1eb-c3e5-4d1f-ad52-eb459588cbbd%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Brent Norris

unread,
Jul 19, 2022, 11:53:53 AM7/19/22
to GAM for Google Workspace
I know this is an old thread, but for anyone that stumbles on this a way to find them based on last login time is with a command like this:

gam config csv_output_row_filter '{"lastLoginTime": "time<-1y"}' print users query "isSuspended=True" lastlogintime

To post to this group, send email to google-ap...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages