GAM is an open source command line tool for making changes to objects in the G Suite Admin Console. It is thoroughly documented at the Github Wiki. The options available for use with GAM are displayed in specific sections on the right-hand side of the GAM Wiki. The scope of what is available to a GFE admin choosing to utilize GAM is vast. Setting up GAM is documented, but if you run into issues don’t hesitate to email email@example.com — this is a great use of Support Hours.
Some examples that may be relevant this time of the school year are covered below.
GAM Single Use Cases
GAM comes into its own when it is combined with either output from itself or CSV files. This is covered in greater detail here.
However again a few example uses are provided below.
Let’s say you want to hide all groups from the Global Address List in G Suite. You would first print out a list of groups:
gam print groups > groups.csv
Then run a bulk command using that group.csv file as input:
gam csv groups.csv gam update group ~Email includeInGlobalAddressList false
To break that down, gam csv groups.csv lets GAM know we’re using the file groups.csv as an input. If you look at that file, it has one column with a header of Email and every row has a single group email address. gam update group ~Email includeInGlobalAddressList false is a full GAM command. Here’s where the bulk action comes in to play. Instead of specifying each individual group to update, we tell GAM to use the Email column in the input csv as our list of groups. The ~ (tilde) tells GAM that is the name of a column header in the CSV. If you have a command that needs to reference multiple columns, you can use them this way.
Note: Column headers are case specific.
That works great, but outputting to a CSV file is an extra step. We can move a bit faster by taking the output of one GAM command and piping it to a bulk command. By piping input from GAM back into itself using a special pipe character, it is possible to perform changes on as many objects as required on a G Suite domain. Take this command for example:
gam print groups | gam csv – gam update group ~Email includeInGlobalAddressList true
Prints out a list of groups in CSV text format with a header called Email and it is then piped back into GAM using the ‘|’ character, instructing GAM that a csv is being used as input. It is then told to work on each row in the column ‘Email’ and change the setting to force the display of all groups in the Global Address List.
Bulk changes to Groups based on CSV input file
It is possible to obtain a list of groups
gam print groups allfields > c:\DestinationFolder\GroupsExport.csv
Then carry out modifications to the columns in this CSV using Excel/Sheets and then pipe that CSV back into GAM to action those changes. GAM will then alter each and every group as required.
gam csv alteredcsvfile.csv gam update group ~Email “SettingToBeAltered” ~”SettingColumnHeader”
gam csv alteredcsvfile.csv gam update group ~”Email” include_in_global_address_list ~”includeInGlobalAddressList” show_in_group_directory ~”showingroupdirectory”
This will hide all groups from the Global Address List (autocomplete in Drive/Gmail) and the Groups directory (being searchable via https://groups.google.com).
Moving all suspended users into a specific OrgUnit:
gam print users query “isSuspended=true orgUnitPath=/Student” | gam csv – gam update user “~primaryEmail” ou /Suspended/Students gal off
Would hunt for suspended users in the /Student OrgUnit and move them to an OrgUnit /Suspended/Students and hides them from the directory.
This is just a small segment of all the capabilities GAM has, have a think about pain points you have with managing your Admin Console daily, GAM can likely help automate this task to some extent if there is an API endpoint available for what you’re trying to do. Feel free to book some time in with our support team by reaching out to firstname.lastname@example.org
Find this article useful? Share it!
Technical Support Analyst
About the Author:
Stephen lives in Utah and enjoys the puzzle of investigating users’ problems and finding potential solutions. A recovering / reformed Gamer, Stephen throws himself into his passion for staying on top of all things Chrome OS and Chromebook related. Prior to joining Amplified IT, Stephen served as a Network Admin in a Therapeutic Boarding School and an IT director, where he implemented G Suite for Education. Stephen has studied computer science and security at Weber State University, Western Governors University. A self-anointed honor, Stephen likes Chromebooks more than almost anyone else in the world.