Remove all traces of old domain from user contacts

204 views
Skip to first unread message

Corey Schneer

unread,
May 30, 2023, 10:06:26 PM5/30/23
to GAM for Google Workspace
Hi,

I would like to remove all the contacts and othercontacts for all my users that match a domain. I used the following command on one user, but it's very slow.

gam user us...@domain.com clear contacts emailmatchpattern ".*@olddomain.com"
gam user us...@domain.com clear othercontacts emailmatchpattern ".*@olddomain.com"

Is there a better way to go about this? Maybe a multiprocess command?

Thank you!

Corey Schneer

unread,
Jun 1, 2023, 8:14:12 AM6/1/23
to GAM for Google Workspace
Can anyone please assist me with this? I tried a similar command to delete accounts for all users with this match pattern and while it seems to work, end users still see the old domain in their other contacts.

Thank you so much

Joseph Grimes (From GAT Labs)

unread,
Jun 1, 2023, 8:44:03 AM6/1/23
to google-ap...@googlegroups.com
Hi Corey,

I don't think the API connects to other contacts at all. So that won't work for you.

What you could do instead that might help in this situation is turn gal off for the email address in the old domain.

Kind regards,

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/f7e883f6-7896-4e5f-97ba-fdf71f98269an%40googlegroups.com.


--
Joe Grimes
GAT Labs Ltd
a:
12 Hume St, Dublin 2, D02 XN44, Ireland
w:gatlabs.com e: sa...@generalaudittool.com
...

GAT has introduced many new features, for a quick overview of the many things you can now do check out our video tutorials from our Youtube channel


Corey Schneer

unread,
Jun 1, 2023, 8:59:01 AM6/1/23
to google-ap...@googlegroups.com
It does. I've done it before for myself, but not for everyone. I may have just gotten it working, but I need to wait for the command to complete to confirm. I used 

gam ou_and_children_ns / delete othercontacts emailmatchpattern ".@olddomain.org"



Ross Scroggs

unread,
Jun 1, 2023, 9:21:49 AM6/1/23
to google-ap...@googlegroups.com
Corey,

You want .*@olddomain.org in the emailmatchpattern, add query "olddomain.org" and Google will hep do the filtering.

Ross

gam ou_and_children_ns / delete othercontacts emailmatchpattern ".*@olddomain.org" query "olddomain.org"

----
Ross Scroggs



Corey Schneer

unread,
Jun 1, 2023, 9:39:34 AM6/1/23
to google-ap...@googlegroups.com
It seems like this command is only removing a maximum of 10 othercontacts per user. Do you know of a way around this limitation? Perhaps I can query all users with othercontacts that match this domain into a large CSV and run a command against that?

Kim Nilsson

unread,
Jun 5, 2023, 4:21:52 AM6/5/23
to GAM for Google Workspace
That was a strange limitation.
So if you run it twice it will delete another 10 contacts, and again and again, but never more than 10 in a single run?

Corey Schneer

unread,
Jun 5, 2023, 11:08:51 AM6/5/23
to google-ap...@googlegroups.com
Yes,

Ross assisted me with a workaround. First I make an export of all othercontacts in my org that match an emailmatchpattern value.

gam config auto_batch_min 1 num_threads 20 redirect csv ./othercontactslist.csv multiprocess redirect stdout ./listothercontacts.txt multiprocess redirect stderr stdout ou_and_children_ns / print othercontacts emailmatchpattern ".*@domain.org"

For some reason the addition of a query at the end of this command will only produce ten results per user. Omitting it will provide all of the results. I've taken the export from this command and ran this command against it to delete the other contacts one by one. It's slow going and tends to overload the People API, but I'm finding success with it.

gam config num_threads 10 redirect stdout ./deleteothercontacts.txt multiprocess redirect stderr stdout csv ./othercontactslist.csv gam user "~User" delete othercontacts "~resourceName"




On Mon, Jun 5, 2023 at 4:21 AM Kim Nilsson <there.is.no...@gmail.com> wrote:
That was a strange limitation.
So if you run it twice it will delete another 10 contacts, and again and again, but never more than 10 in a single run?

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages