how to add email alias in bulk

7,969 views
Skip to first unread message

Mearaj Shaikh

unread,
Feb 10, 2017, 2:39:41 PM2/10/17
to GAM for G Suite

Hi ,

anybody can help me on how to add email alias in bulk via CSV or batch file

Kevin Melillo

unread,
Feb 10, 2017, 2:50:27 PM2/10/17
to google-ap...@googlegroups.com
Good afternoon.  GAM can be used to add aliases.  The command for this is the following:

gam create alias <alias> user <username>

If you create a CSV file with the username and alias needed, then you can do a bulk add alias with GAM.  You can format the file as follows:

ALIAS_ADD.CSV
user,alias

You can then use the following command to use the CSV for the batch update.

gam csv ALIAS_ADD.CSV gam create alias ~alias user ~user



On Fri, Feb 10, 2017 at 1:51 PM, Mearaj Shaikh <mea...@shivaami.com> wrote:

Hi ,

anybody can help me on how to add email alias in bulk via CSV or batch file

--
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-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/dda1c0f5-4502-4b7f-a3c8-c63f65edb140%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kevin Melillo
Electronic Communications Analyst
Information Technology
445 Hoes Lane
Piscataway, NJ 08854

Phone:732-465-6609 | Mobile: 732-609-4331

Ross Scroggs

unread,
Feb 10, 2017, 3:13:59 PM2/10/17
to google-ap...@googlegroups.com
Mearaj/Kevin,

I would suggest putting the column names in quotes if you are on a platform other than Windows (although it is OK on Windows.)
Some shells look at ~xyz and may transform it if there is a user named xyz on the system; the quotes eliminate this behavior.

gam csv ALIAS_ADD.CSV gam create alias "~alias" user "~user"

Ross

On Fri, Feb 10, 2017 at 11:50 AM, Kevin Melillo <k.me...@ieee.org> wrote:
Good afternoon.  GAM can be used to add aliases.  The command for this is the following:

gam create alias <alias> user <username>

If you create a CSV file with the username and alias needed, then you can do a bulk add alias with GAM.  You can format the file as follows:

ALIAS_ADD.CSV
user,alias

You can then use the following command to use the CSV for the batch update.

gam csv ALIAS_ADD.CSV gam create alias ~alias user ~user


On Fri, Feb 10, 2017 at 1:51 PM, Mearaj Shaikh <mea...@shivaami.com> wrote:

Hi ,

anybody can help me on how to add email alias in bulk via CSV or batch file

--
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-manager+unsubscribe...@googlegroups.com.
--
Kevin Melillo
Electronic Communications Analyst
Information Technology
445 Hoes Lane
Piscataway, NJ 08854

Phone:732-465-6609 | Mobile: 732-609-4331

--
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-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.

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



--

Michael Tremblay

unread,
Jun 9, 2017, 4:42:42 PM6/9/17
to GAM for G Suite
Does anyone have a script to pull an easy list of aliases into a CSV for use by the GAM command? I have been editing the data manually after extracting from EMC but the aliases are in a string and not overly handy to separate. I am able to do it by removing quotes in Notepad then replacing spaces in the addresses column with commas. This allowed me to import into Excel with each once in separate column but now I have to pull the data from each row to make x rows in GAM CSV for each user/group with each alias.
so from 
DisplayName PrimarySmtpAddress EmailAddresses
company_name_Technical_Architecture _Technical_A...@domain.com company_name_Technical_Architecture _Technical_Architecture _CTA_GRP CPN_Technical_Architecture

TO
user, Alias
company_name_Technical_Architecture, _Technical_Architecture
company_name_Technical_Architecture, _CTA_GRP
company_name_Technical_Architecture, CPN_Technical_Architecture
company_name_Technical_Architecture, alias4
company_name_Technical_Architecture, alias5

and so on....
Quite a pain..

Thank you,
Mike

On Friday, February 10, 2017 at 3:13:59 PM UTC-5, Ross Scroggs wrote:
Mearaj/Kevin,

I would suggest putting the column names in quotes if you are on a platform other than Windows (although it is OK on Windows.)
Some shells look at ~xyz and may transform it if there is a user named xyz on the system; the quotes eliminate this behavior.

gam csv ALIAS_ADD.CSV gam create alias "~alias" user "~user"

Ross
On Fri, Feb 10, 2017 at 11:50 AM, Kevin Melillo <k.me...@ieee.org> wrote:
Good afternoon.  GAM can be used to add aliases.  The command for this is the following:

gam create alias <alias> user <username>

If you create a CSV file with the username and alias needed, then you can do a bulk add alias with GAM.  You can format the file as follows:

ALIAS_ADD.CSV
user,alias

You can then use the following command to use the CSV for the batch update.

gam csv ALIAS_ADD.CSV gam create alias ~alias user ~user


On Fri, Feb 10, 2017 at 1:51 PM, Mearaj Shaikh <mea...@shivaami.com> wrote:

Hi ,

anybody can help me on how to add email alias in bulk via CSV or batch file

--
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-manager+unsub...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
--
Kevin Melillo
Electronic Communications Analyst
Information Technology
445 Hoes Lane
Piscataway, NJ 08854

Phone:732-465-6609 | Mobile: 732-609-4331

--
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-manager+unsub...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.



--

Ross Scroggs

unread,
Jun 9, 2017, 5:40:25 PM6/9/17
to google-ap...@googlegroups.com
Michael,

This would be a fairly trivial Python script. I'm a little unclear on your columns. Is PrimarySmtpAddress the main address and EmailAddresses the aliases?
What separates the columns in the EMC data?

Ross

On Fri, Jun 9, 2017 at 1:40 PM, Michael Tremblay <ioadm-m...@payments.ca> wrote:
Does anyone have a script to pull an easy list of aliases into a CSV for use by the GAM command? I have been editing the data manually after extracting from EMC but the aliases are in a string and not overly handy to separate. I am able to do it by removing quotes in Notepad then replacing spaces in the addresses column with commas. This allowed me to import into Excel with each once in separate column but now I have to pull the data from each row to make x rows in GAM CSV for each user/group with each alias.
so from 
DisplayName PrimarySmtpAddress EmailAddresses
company_name_Technical_Architecture _Technical_Architecture@domain.com company_name_Technical_Architecture _Technical_Architecture _CTA_GRP CPN_Technical_Architecture

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsubscribe...@googlegroups.com.
--
Kevin Melillo
Electronic Communications Analyst
Information Technology
445 Hoes Lane
Piscataway, NJ 08854

Phone:732-465-6609 | Mobile: 732-609-4331

--
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-manager+unsubscribe...@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.



--

--
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-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.

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



--

Ross Scroggs

unread,
Jun 9, 2017, 6:04:35 PM6/9/17
to google-ap...@googlegroups.com
Michael,

Here is a sample script. It can be tweaked if my assumptions are off.

Ross

#!/usr/bin/env python                                                                                                                                                                                                   

"""                                                                                                                                                                                                                     

# Purpose: Create a CSV file with columns: User, Alias; from EMC exported data with columns: DisplayName, PrimarySmtpAddress, EmailAddresses.                                                                           

# For each alias email address in the space separated list "EmailAddresses", output a row with PrimarySmtpAddress in the User column and the alias email address in the Alias column.                                   

# Usage:                                                                                                                                                                                                                

# 1: Export EMC data to EMCData.csv                                                                                                                                                                                     

# 2: python GetEMCAliases.py EMCData.csv EMCAliases.csv                                                                                                                                                                 

# 3: Inspect EMCAliases.csv to make sure that it is reasonable                                                                                                                                                          

# 4: Create the aliases in Gam                                                                                                                                                                                          

#  $ gam csv EMCAliases.csv gam create alias "~Alias" user "~User"                                                                                                                                                      

"""


import csv

import sys


if (len(sys.argv) > 2) and (sys.argv[2] != '-'):

  outputFile = open(sys.argv[2], 'wb')

else:

  outputFile = sys.stdout

outputFile.write('User,Alias\n')

if (len(sys.argv) > 1) and (sys.argv[1] != '-'):

  inputFile = open(sys.argv[1], 'rb')

else:

  inputFile = sys.stdin


for row in csv.DictReader(inputFile):

  for alias in row['EmailAddresses'].split():

    outputFile.write('{0},{1}\n'.format(row['PrimarySmtpAddress'], alias))


inputFile.close()

outputFile.close()



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.



--



--

Michael Tremblay-Admin

unread,
Jun 9, 2017, 8:43:57 PM6/9/17
to google-ap...@googlegroups.com
Hey Ross,

The emc output is txt or csv regardless the separation is comma and again within the EmailAddresses column is a space deliminated string within a set of quotes like so "aliasname1@domainname aliasname2@domainname aliasx@domainname"

I thought I might try using python to do it but still a bit new to python. Figured I would ask first thinking someone might have already done this and I would save time writing the code.

There is more logic that I would write in to check then sync the displayname and the primary email address while adding old email address as alias when they do not match.means calling powershell cmdlets to cleanup AD object Distribution Groups in prep to use GCDS to sync the groups.

If you have a chunk of python code that I can use to open file and read in the data to get me going that would be great. Also if you know the names of built in functions to manipulate the quoted string to pull the data out would be great help along with writing out the simple csv file for GAM. I could use some guidance in diving into Python.

Thank you,
Mike
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.



--

--
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/OhHtWXl0s7E/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.

Michael Tremblay-Admin

unread,
Jun 9, 2017, 8:46:44 PM6/9/17
to google-ap...@googlegroups.com
Hi Ross,

Just saw the sample you sent. Thanks I will try this out.

Thanks a bunch.

Cheers, 
Mike 

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/OhHtWXl0s7E/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.

Ross Scroggs

unread,
Jun 9, 2017, 9:12:48 PM6/9/17
to google-ap...@googlegroups.com
MIke,

I can modify the script, just detail what processing you'd like.

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.

Michael Tremblay

unread,
Jun 12, 2017, 1:10:41 AM6/12/17
to GAM for G Suite
Hi Ross,

You Rock....Ross the Boss!! 
Hey worked like a charm except that it expected binary read/write but minor change...I was able to update 25 groups in secs.

Now will take a look at doing the users to update their aliases using GAM.

Have some AD clean up to do for groups but this was great, will now build off this script to do more. If I get stuck I will let you know and when I succeed I will post resultant code here for future use.

TTYL!!
Mike
DisplayName PrimarySmtpAddress EmailAddresses
company_name_Technical_Architecture _Technical_A...@domain.com company_name_Technical_Architecture _Technical_Architecture _CTA_GRP CPN_Technical_Architecture

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
--
Kevin Melillo
Electronic Communications Analyst
Information Technology
445 Hoes Lane
Piscataway, NJ 08854

Phone:732-465-6609 | Mobile: 732-609-4331


--
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-manager+unsub...@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.



--

--
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-manager+unsub...@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.



--



--

--
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/OhHtWXl0s7E/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-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

--
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-manager+unsub...@googlegroups.com.

YehiaB

unread,
Aug 29, 2017, 3:49:17 PM8/29/17
to GAM for G Suite
Hello,
So I know this is a basic question, but I'm struggling to find an answer. 

In all batch operations, there is a step that entails creating a CSV file. I create the CSV file on my hard drive, but not sure how to refer to it in the command. i.e. I understand the commands and how to create the file with the columns etc, but I keep getting 

"ERROR: [Errno 2] No such file or directory:"

because I'm unsure where to upload/save the csv file. Any ideas?


On Friday, February 10, 2017 at 9:50:27 PM UTC+2, k.melillo wrote:
Good afternoon.  GAM can be used to add aliases.  The command for this is the following:

gam create alias <alias> user <username>

If you create a CSV file with the username and alias needed, then you can do a bulk add alias with GAM.  You can format the file as follows:

ALIAS_ADD.CSV
user,alias

You can then use the following command to use the CSV for the batch update.

gam csv ALIAS_ADD.CSV gam create alias ~alias user ~user


On Fri, Feb 10, 2017 at 1:51 PM, Mearaj Shaikh <mea...@shivaami.com> wrote:

Hi ,

anybody can help me on how to add email alias in bulk via CSV or batch file

--
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-manager+unsub...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.

k.melillo

unread,
Aug 29, 2017, 4:00:59 PM8/29/17
to GAM for G Suite
With the following command

gam csv ALIAS_ADD.CSV gam create alias ~alias user ~user

The red part of the text will be the full path and name of the csv file.  So for example, if you had the file located in C:\CSVFILES you could use the following

gam csv C:\CSVFILES\ALIAS_ADD.CSV gam create alias ~alias user ~user

Does that answer the question?
Reply all
Reply to author
Forward
0 new messages