Pulling list of user accounts aliases

12,192 views
Skip to first unread message

Chuck W. Williams

unread,
Nov 10, 2016, 11:42:25 AM11/10/16
to GAM for G Suite
Hi guys,

Is there a command to only pull a list of users aliases separately from the using gam info "user" command and pipe the results to a .csv file or to drive

Thanks

Graham Ingleby

unread,
Nov 10, 2016, 11:44:50 AM11/10/16
to GAM group
You have the print command

gam print aliases [todrive]


Does that give you what you are looking for?


 

 Graham Ingleby | Google Cloud Consultant | +44 1344 203395 | ging...@ancoris.com

Google+      

Powered by Ancoris Signatures


--
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/4e89eda2-241f-440b-b7be-a668787752f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



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




Chuck W. Williams

unread,
Nov 10, 2016, 11:51:49 AM11/10/16
to GAM for G Suite
Thanks Graham, I see this will pull "all users aliases" in the domain, it seems there is not a command to pull aliases for just targeted list of users.  This will still work as we'll  just filter for the targeted users in the resulting file...thanks a ton.

Regards


On Thursday, November 10, 2016 at 11:44:50 AM UTC-5, Graham Ingleby wrote:
You have the print command

gam print aliases [todrive]


Does that give you what you are looking for?


 

 Graham Ingleby | Google Cloud Consultant | +44 1344 203395 | ging...@ancoris.com

Google+      

Powered by Ancoris Signatures


On 10 November 2016 at 16:42, Chuck W. Williams <chuck.wi...@nielsen.com> wrote:
Hi guys,

Is there a command to only pull a list of users aliases separately from the using gam info "user" command and pipe the results to a .csv file or to drive

Thanks

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

Andrew

unread,
Apr 10, 2019, 10:40:27 AM4/10/19
to GAM for G Suite
Not the most efficient, but I just pipe the output into grep/awk to find the aliases I'm looking for.

gam print aliases nogroups | grep per...@domain.com | sed 's/,/ /g' | awk '{print $1}'

I was hoping this was built-in to gam, but I haven't found a better way yet.

Ross Scroggs

unread,
Apr 10, 2019, 11:21:23 AM4/10/19
to google-ap...@googlegroups.com
Andrew,

gam print aliases query "email='per...@domain.com'"


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.

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


--

Andrew

unread,
Apr 10, 2019, 12:17:22 PM4/10/19
to GAM for G Suite
Ohhh ... nice.  Thanks.


On Wednesday, April 10, 2019 at 11:21:23 AM UTC-4, Ross Scroggs wrote:
Andrew,

gam print aliases query "email='per...@domain.com'"


Ross


On Wed, Apr 10, 2019 at 7:40 AM Andrew <and...@terminal.io> wrote:
Not the most efficient, but I just pipe the output into grep/awk to find the aliases I'm looking for.

gam print aliases nogroups | grep per...@domain.com | sed 's/,/ /g' | awk '{print $1}'

I was hoping this was built-in to gam, but I haven't found a better way yet.

On Thursday, November 10, 2016 at 11:42:25 AM UTC-5, Chuck W. Williams wrote:
Hi guys,

Is there a command to only pull a list of users aliases separately from the using gam info "user" command and pipe the results to a .csv file or to drive

Thanks

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


--
Ross Scroggs

John Paraskevopoulos

unread,
Sep 23, 2019, 7:05:04 AM9/23/19
to GAM for G Suite
How would you query and print aliases of a list in a .csv file?


On Wednesday, April 10, 2019 at 6:21:23 PM UTC+3, Ross Scroggs wrote:
Andrew,

gam print aliases query "email='per...@domain.com'"


Ross


On Wed, Apr 10, 2019 at 7:40 AM Andrew <and...@terminal.io> wrote:
Not the most efficient, but I just pipe the output into grep/awk to find the aliases I'm looking for.

gam print aliases nogroups | grep per...@domain.com | sed 's/,/ /g' | awk '{print $1}'

I was hoping this was built-in to gam, but I haven't found a better way yet.

On Thursday, November 10, 2016 at 11:42:25 AM UTC-5, Chuck W. Williams wrote:
Hi guys,

Is there a command to only pull a list of users aliases separately from the using gam info "user" command and pipe the results to a .csv file or to drive

Thanks

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


--
Ross Scroggs

Ross Scroggs

unread,
Sep 23, 2019, 8:38:14 AM9/23/19
to google-ap...@googlegroups.com
John,

Assuming that you have a CSV file (users.csv) with a header primaryEmail (adjust as necessary)
Basic GAM.
gam csv users.csv gam print aliases query "email=~~primaryEmail~~" nogroups > aliases.csv
You'll have to delete all rows (except the first) that look like this: Alias,Target,TargetType

Advanced GAM:
gam redirect csv ./aliases.csv multiprocess csv users.csv gam print aliases query "email=~~primaryEmail~~" nogroups
There are no extra header rows to delete.

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/09d10e12-ca54-47f2-8498-8b7803420312%40googlegroups.com.

John Paraskevopoulos

unread,
Sep 23, 2019, 3:38:52 PM9/23/19
to GAM for G Suite
Thanks...this works fine!


On Monday, September 23, 2019 at 3:38:14 PM UTC+3, Ross Scroggs wrote:
John,

Assuming that you have a CSV file (users.csv) with a header primaryEmail (adjust as necessary)
Basic GAM.
gam csv users.csv gam print aliases query "email=~~primaryEmail~~" nogroups > aliases.csv
You'll have to delete all rows (except the first) that look like this: Alias,Target,TargetType

Advanced GAM:
gam redirect csv ./aliases.csv multiprocess csv users.csv gam print aliases query "email=~~primaryEmail~~" nogroups
There are no extra header rows to delete.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Dale Courtney

unread,
Jul 7, 2020, 12:46:55 PM7/7/20
to GAM for G Suite
Ross, 

Is it possible to run this command with a ≠ option? ie., 

     gam print aliases query "email='per...@domain.com'"

I'm trying to return aliases that exist but not for certain managers. 

Thanks. 

Kim Nilsson

unread,
Jul 8, 2020, 12:30:52 PM7/8/20
to GAM for G Suite

Dale Courtney

unread,
Jul 8, 2020, 1:18:43 PM7/8/20
to GAM for G Suite
Kim, 

I tried this with my own account: 

gam print aliases query "email!='cour...@economicmodeling.com'"


And I got the error message 

Alias Print Failed: Query (email!='cour...@economicmodeling.com') Invalid

best,
Dale


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

Ross Scroggs

unread,
Jul 8, 2020, 1:35:41 PM7/8/20
to google-ap...@googlegroups.com
Dale,

<QueryUser> ::= <String>

        See: https://developers.google.com/admin-sdk/directory/v1/guides/search-users


The API doesn't support != in the query.


If you want aliases for a specific set of people do the following.

Make a CSV file GetAliases.csv with one column email.


gam redirect csv Aliases.csv multiprocess csv GetAliases.csv gam print aliases query "email=~~email~~" nogroups


Ross





--

Dale Courtney

unread,
Jul 8, 2020, 1:43:39 PM7/8/20
to GAM for G Suite
Thanks, Ross. Makes sense. 

best,
Dale


Reply all
Reply to author
Forward
0 new messages