Need to remove aliases all at once using GAM

2,754 views
Skip to first unread message

Jestony Mirarza

unread,
Jul 31, 2017, 3:02:29 PM7/31/17
to GAM for G Suite
Hi all!

I have been introduced to this GAM tool and seems to be very effective for my concern. The problem is, i am not tech savvy enough to run the tool.

Can you help me create an automatic script like a batch file?

I have more than 300 users in my G Suite account and my users created tons of email aliases for their accounts. I want to remove these aliases in bulk. Can someone help me?

Many thanks!

Ross Scroggs

unread,
Jul 31, 2017, 6:41:00 PM7/31/17
to google-ap...@googlegroups.com
Jestony,

This is basically what you what but you should apply some careful thinking before doing this.
gam print aliases > AllAliases.csv
AllAliases.csv will have the headers: Alias,Target,TargetType
TargetType will be User or Group

If you want to delete all aliases (think carefully) do:
gam csv AllAliases.csv gam delete alias ~Alias ~TargetType ~Target

If you're only trying to delete User aliases, edit AllAliases.csv, delete all lines that have TargetType = Group, save that file as UserAliases.csv.
If you want to preserve some user aliases, delete them from UserAliases.csv
gam csv UserAliases.csv gam delete alias ~Alias ~TargetType ~Target

If you want to get rid of some group aliases, edit AllAliases.csv, delete all lines that have TargetType = User, save that file as GroupAliases.csv.
If you want to preserve some group aliases, delete them from GroupAliases.csv
gam csv GroupAliases.csv gam delete alias ~Alias ~TargetType ~Target

Ross

--
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/a9671d4e-0be6-4d86-acda-32d934206e13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steve Larsen

unread,
May 14, 2022, 4:34:33 PM5/14/22
to google-ap...@googlegroups.com
Ross - I kept getting errors when I attempted the following which I thought was correct based on that format
gam select my-domain csv gsheet st...@domain.com <sheet-id> "domain.com - Aliases" gam delete alias ~Alias ~TargetType ~Target

ERROR: Extra arguments
Help: Syntax in file /home/steve/bin/gamadv-xtd3/GamCommands.txt
Help: Documentation is at https://github.com/taers232c/GAMADV-XTD3/wiki
Command: gam select my-domain delete alias user@temp.domain.com >>>user user@domain.com<<<



Then I updated that to be the following and it worked
gam select my-domain csv gsheet st...@domain.com <sheet-id> "domain.com - Aliases" gam delete alias ~TargetType ~Alias 

Ross Scroggs

unread,
May 15, 2022, 5:32:57 PM5/15/22
to google-ap...@googlegroups.com
gam select my-domain csv gsheet st...@domain.com <sheet-id> "domain.com - Aliases" gam delete alias ~TargetType ~Alias

This will work if you change delete to remove
gam select my-domain csv gsheet st...@domain.com <sheet-id> "domain.com - Aliases" gam removee alias ~Alias ~TargetType ~Target
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