GAM and Managing Your Admin Console

GAM is an open-source command-line tool that streamlines the management of objects within the Google Admin console. Detailed documentation for GAM can be found on its GitHub Wiki. The link is from the standard GAM, for installing we recommend installing GAM advanced version. The various options available with GAM are organized into specific sections on the right-hand side of the Wiki. The capabilities available to a Google Workspace for Education admin using GAM are extensive.

Setting Up GAM

Comprehensive setup instructions are provided in the documentation. However, if you encounter any issues, don’t hesitate to contact us. If you have hours remaining on a support subscription, you are one step closer to accessing the GAM: Getting Started Support Stack. You can connect with our support team by emailing support@amplifiedit.com. To purchase support hours, contact a Google Customer Support Specialist.

GAM Single Use Cases

GAM excels when used with its own output or CSV files. More detailed information can be found here. Below are some practical examples relevant during the school year.

Example: Hiding All Groups from the Global Address List

To hide all groups from the Global Address List in Google Workspace, first, print out a list of groups:

gam print groups > groups.csv

Then, run a bulk command using the groups.csv file as input:

gam csv groups.csv gam update group ~Email includeInGlobalAddressList false

Explanation:

  • gam csv groups.csv informs GAM to use groups.csv as the input file.
  • The CSV file should have a column header Email and each row should contain a group email address.
  • gam update group ~Email includeInGlobalAddressList false is the command to update each group. The ~ (tilde) indicates a column header in the CSV.

Note: Column headers are case-sensitive.

Example: Piping Commands

For faster execution, you can pipe the output of one GAM command into another using the | character. For instance:

gam print groups | gam csv – gam update group ~Email includeInGlobalAddressList true

This command prints a list of groups in CSV format and pipes it back into GAM. GAM then updates each group to be included in the Global Address List.

Useful Commands

Bulk Changes to Groups Based on CSV Input

To obtain a list of groups:

gam print groups allfields > c:\DestinationFolder\GroupsExport.csv

You can then modify the columns in this CSV using Excel or Google Sheets and pipe it back into GAM:

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 and the Groups directory.

Moving Suspended Users to a Specific OrgUnit

To move all suspended users to a specific OrgUnit:

gam print users query "isSuspended=true orgUnitPath=/Student" | gam csv – gam update user "~primaryEmail" ou /Suspended/Students gal off

This command finds suspended users in the /Student OrgUnit and moves them to the /Suspended/Students OrgUnit, hiding them from the directory.

Conclusion

This is just a small sample of GAM’s capabilities. Consider the daily pain points you encounter while managing your Admin console. GAM can likely help automate these tasks if there is an API endpoint available. For further assistance, contact support@amplifiedit.com.

 

 

 

 

Setting up GAM is documented, but if you run into issues, don’t hesitate to contact us. If you currently have hours on a support subscription, you are one step closer to the GAM: Getting started Support Stack and you can connect with the support team by emailing support@amplifiedit.comTo purchase support hours, please fill out this form and an account manager will connect with you.

Some examples that may be relevant during 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 Google Workspace. 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 Google Workspace 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.

Useful commands

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 support@amplifiedit.com.

 

Document Version Date Description of Change
1.0 7/11/2024 Rewrote text, reverified. 

 

Articles in this section

See more