Update your Bookmarks to https://sites.google.com/view/gam--commands/home
gam user <Manager Email Address> add groups manager <Group 1 Email Address>,<Group 2 Email Address>,<ETC>
gam create alias <Alias Email Address> group <Group Email Address>
gam remove alias <Group Email Address> group <Alias Email Address>
Create a CSV file with just the email addresses of the groups to delete
gam csv <CSV File> gam delete group ~email
gam user <User Email Address> delete groups
Remove the users, in an OU, from all their groups.
gam ou_and_children "</Path/To/OU>" print email | gam csv - gam user ~primaryEmail delete groups
gam info group <group name>
Show just the current fields.
gam info group <group name> nodeprecated
Date a group was created
gam info group <Group Email Address> cifields createtime
Create a sheet of Groups with no members. These groups may have Managers and Owners.
gam config csv_output_row_filter "directMembersCount:count=0" print groups directmemberscount todrive
gam config csv_output_row_filter "'MEMBER:count=0','MANAGER:count=0','OWNER:count=0'" all users print groups countsonly todrive
Or
gam config csv_output_row_filter "TotalCount:count=0" print groups members managers owners totalcount countsonly todrive
gam group <group name> print allfields todrive
To just show the users in the group
gam group <group name> print users fields name
gam print groups settings todrive [OR > groups.csv]
gam print groups domain <your domain> allfields todrive
Add notsuspended to ignore suspended users.
gam print groups members domain <your domain> todrive
gam print groups member <User Email Address>
gam print groups query memberkey='<user email address inc @Domain>' todrive
This will only show direct memebership. It will not show where a User is a memeber of a sub-group.
gam print groups member <user email address>
Include a cell of the members, managers and owners as well the count of each type.
gam print groups member <user email address> members managers owners todrive
Or only show the counts columns
gam print groups member <user email address> members managers owners countsonly todrive
Show the counts columns and total count (sum) of the members, managers and owners columns.
gam print groups member <user email address> members managers owners countsonly totalcount todrive
Total count for groups larger than 100. Change 100 to a different number as required.
gam config csv_output_row_filter "TotalCount:count>=100" print groups countsonly totalcount members manager owners todrive
Only show the group email addresses, add csv_output_header_filter email.
gam config csv_output_row_filter "TotalCount:count>=100" csv_output_header_filter email print groups countsonly totalcount members managers owners
If totalcount column is zero (0) then indicated an empty group.
gam print groups domain <Your Domain> members managers owners countsonly totalcount todrive
Find groups starting with ...
gam print groups query "email:<Start of Name>*"
Anyone Can Post
gam print groups domain <domain.com> matchsetting whocanpostmessage anyone_can_post owners todrive
gam config csv_output_row_filter "enableCollaborativeInbox:boolean:true" redirect csv ./CollaborativeInboxGroups.csv print groups fields enableCollaborativeInbox todrive
This example will print the list of goups starting with <Text> and where the setting whoCanJoin is ALL_IN_DOMAIN_CAN_JOIN. Change setting as needed. Remove not if you want groups starting with the <Text>.
gam config csv_output_row_filter "whoCanJoin:text=ALL_IN_DOMAIN_CAN_JOIN" print groups emailmatchpattern not '<Text>.+' settings fields whoCanJoin todrive
gam print groups fields spammoderationlevel todrive
The options are emailmatchpattern, namematchpattern or descriptionmatchpattern. See this section for an explaination of the regex search options
gam print group-members domain <Your Domain> emailmatchpattern not '^<Text to Match>.*' roles owners
For an Individual Group.
The _ns (not suspended) at the end of the group_ns will ensure that only active members will be listed.
gam print group-members group_ns <Group Email Address> todrive
For All Groups
gam print group-members domain <your domain> todrive
gam print group-members group <Group Email Address> roles owners,managers
gam print group-members types group todrive
To see when a user is a member of a group including when they are memebers of sub-groups
gam config show_gettings false print group-members recursive memberemaildisplaypattern "<User Email Address>" members todrive
gam print group-members types group todrive
gam print group-members group <Group Email Address> recursive noduplicates todrive
gam print group-members memberemaildisplaypattern ".*@<Domain To Check>"
Check Groups in your Domain, which contain members in a specific Domain, such as gmail.com. The added emailmatchpattern option has been added where you want to exclude specific groups. For example, we have groups that are automatically generated, which all start with the same prefix. These can be excluded as they can never contain anything other than Domain users.
gam print group-members domain <Your Domain> emailmatchpattern not '^<Prefix to Exclude>.*' memberemaildisplaypattern ".*<Domain To Check>"
Find group members who are not in your Domain.
gam print group-members memberemailskippattern ".*@Domain.com" todrive
Users not in your Domain and not is groups with a set prefix.
gam print group-members emailmatchpattern not '^<Prefix to Exclude>.*' memberemailskippattern ".*@Domain.com" todrive
Remove emailmatchpattern not '^<Prefix to Exclude>.*' if you do not need to exclude groups with a specific prefix.
gam print group-members domain <Your Domain> emailmatchpattern not '^<Prefix to Exclude>.*' suspended todrive
Change ou_and_children </Path/To/OU> to all users, group <GroupName> as required.
gam config csv_output_row_filter "Groups:count=0" ou_and_children_ns </Path/To/OU> print groupslist todrive
Messages in the last X days, change 8d as needed.
gam user <User Email Address> print messages query 'list:<Group Email Address> newer_than:8d' countsonly
This command can be used to get the settings for a single group.
gam redirect csv ./groups.csv print groups select <Group Email Address> settings formatjson quotechar "'"
Download and make the changes to the JSON file and then upload and run
gam csv ./groups.csv quotechar "'" gam update group ~email json ~JSON-settings
OR
gam redirect stdout ./<File Name>.json info group <Group Email Address> formatjson nousers
gam update group <Group Email Address> json <File Name>.json
The <Domain To Ignore> is generally your Domain, unless you are running on behalf of another Domain. You may also need to change TRUE to FALSE to see the groups that do not allow external members, but still have them, i.e. the AllowExternalMembers setting was changed after external members were added.
This command will create a CSV of only the Groups that have External Members and will list the members, one per line.
gam print groups matchsetting allowExternalMembers TRUE | gam redirect csv ./ExternalMembers.csv multiprocess csv - gam print groupmembers group ~email memberemailskippattern ".*@<Domain To Ignore>$"
OR as two separate commands
Useful if you want to run multiple commands on the initial output file e.g. on the ExternalTrue.csv file
gam redirect csv ./ExternalTrue.csv print groups matchsetting allowExternalMembers TRUE
Then
gam redirect csv ./ExternalMembers.csv multiprocess csv ./ExternalTrue.csv gam print groupmembers group ~email memberemailskippattern ".*@<Domain To Ignore>$"
OR a single command
To create Google Sheet, one group per line, which will need some filtering. Each group is listed, even if they do not have external members. Also external members all appear in a single cell.
gam print groups matchsetting allowExternalMembers TRUE members memberemailskippattern ".*@<Domain To Ignore>$" todrive
With various options, change the italics as needed.
gam create group <Group Email Address> name <Group Name> description <Group Description> gal false showingroupdirectory false whocanadd none_can_add whocanjoin invited_can_join whocanleavegroup none_can_leave whocanviewgroup all_managers_can_view whocanviewmembership all_managers_can_view whocanpostmessage none_can_post archiveonly true
Create a groups and add teachers as managers so they can add students as required. Hide from the directory.
gam csv <csv file name>.csv gam create group ~email
gam csv <csv file name>.csv gam update group ~email add member <Manager Email Address>
gam csv <csv file name>.csv gam update group ~email update manager user <User Email Address>
gam csv <csv file name>.csv gam update group ~email whocanpostmessage all_in_domain_can_post
gam csv <csv file name>.csv gam update group ~email includeinglobaladdresslist false
For Basic GAM, run;-
export GAM_CSV_ROW_FILTER='{"Owners": "regex:<User Email Address>"}'
then run
gam print groups member <User Email Address> owners delimiter " " todrive
For GAMADV-XTD3 run;-
gam config csv_output_row_filter '{"Owners": "regex:<User Email Address>"}' print groups member <User Email Address> owners delimiter " " todrive
OR
gam print groups showownedby <User Email Address> todrive tdtitle
The todrive option is not needed. If used it will create a Google Sheet as well as the CSV. Change the CSV file names as needed.
NB, when checking the CSV give different results to the Google Sheet. The CSV read commas in the description field and created additional rows.
gam config csv_output_row_filter "OwnersCount:count=0" redirect csv ./owner_less_groups.csv print groups fields name,description ownerscount todrive
The <User Email Address> can be a user or a group. By default Delivery setting is 'All Email'
gam update group <Group Email Address> add member <User Email Address>
gam csv <CSV File Name>.csv gam update group <Group Email Address> add member user ~Email
Choose whether to add an OU or OU and it's child OUs. The NS option will only add Non-Suspended users.
gam update group <Group Name> add member [ou_ns | ou_and_children_ns] </Path/To/OU>
Stop emails
gam update group <Group Email Address> update nomail <User Email Address>
Receive emails
gam update group <Group Email Address> update allmail <User Email Address>
gam update group <Group Email Address> add member nomail user <User Email Address>
The group you are updating needs to already be created.
gam config csv_output_row_filter "lastLoginTime:regex:Never" print users fields primaryemail,lastlogintime | gam update group <Group Email Address> sync members csvfile -:primaryEmail
gam update group <Group Email Address> spam_moderation_level [allow|moderate|silently_moderate|reject]
gam update group <Group Email Address> delete user <User Email Address>
Using a Google Sheet listing the email addresses of the users to remove under the Email column.
gam csv gsheet <User Email Address> <File ID> <Sheet Name> gam update group <Group Email Address> delete user ~Email
Other options are allindomaincanpost|allmanagerscanpost|allmemberscanpost|allownerscanpost|anyonecanpost|nonecanpost.
gam update group <Group Email Address> who_can_post_message allownerscanpost
For a single group
gam update group <Group Email Address> who_can_view_membership all_in_domain_can_view
Using a Google Sheet
gam csv gsheet <Sheet Owner Email> <File ID> <Sheet Name> gam update group ~email who_can_view_membership all_in_domain_can_view
Groups starting with
gam config csv_output_row_filter "email:regex:<Starting With>.*@<Your Domain>" print groups | gam csv - gam update group ~email who_can_view_membership all_in_domain_can_view
This setting controls who can view messages. The options are ALL_IN_DOMAIN_CAN_VIEW, ALL_MEMBERS_CAN_VIEW, ALL_MANAGERS_CAN_VIEW or ALL_OWNERS_CAN_VIEW.
gam update group <Group Email Address> whoCanViewGroup ALL_MEMBERS_CAN_VIEW
or, using a Google Sheet
gam csv gsheet <Sheet Owner Email> <File ID> <Sheet Name> gam update group ~email whoCanViewGroup ALL_MEMBERS_CAN_VIEW
gam update group <Group Email Address> includeinglobaladdresslist false
This is not really needed. This is a global setting rather than a setting per individual. Please see https://support.google.com/a/answer/60218?hl=en for more info.
gam group <groupname> profile unshared
<Member Type> = owner|manager|member
<Delivery Type> = allmail|daily|digest|none|nomail
gam update group <Group Email Address> update <Member Type> <Delivery Type> <User Email Address>
Create a CSV of the groups, with column name group. nomail can be replaced with other options
gam csv groups.csv gam update group "~group" update nomail <User Email Address>
Update External members (not sure why I needed this now)
gam csv <CSV File Name>.csv gam update group ~Email allowexternalmembers ~allowExternalMembers
Update the Spam (spammoderationlevel) settings
gam csv <CSV File Name>.csv gam update group ~email spammoderationlevel allow | moderate
gam csv <student_groups>.csv gam select <student.domain> update group ~group copyfrom <group_with_desired_settings>@student.domain
There is no way to suspend a Group, so prevent all users from posting to the group. This requires you to have a CSV file of email addresses of the groups you want to 'suspend'. When running this command some groups needed the archiveonly option set to true, this command makes this change to all the groups.
gam csv <CSV File Name>.csv gam update group ~email whocanpostmessage NONE_CAN_POST archiveonly true
gam update group <Group Email Address> whoCanBanUsers OWNERS_AND_MANAGERS
gam update group <group email address> isarchived yes
If you want to ensure all group mail is archived
gam config csv_output_row_filter "'isArchived:regex:false'" print groups fields isArchived | gam csv - gam update group ~email isArchived true
Or to remove archiving for all groups
gam config csv_output_row_filter "'isArchived:regex:true'" print groups fields isArchived | gam csv - gam update group ~email isArchived false
Change the <Moderate Option> from one of these options all_members|owners_and_managers|owners_only|none
gam update group <Group Email Address> whocanmoderatemembers <Moderate Option>
gam update group <current email> email <new email>
Change the <Leave Option> from one of these options all_members_can_leave|all_managers_can_leave|all_owners_can_leave|none_can_leave
gam update group <Group Email Address> whocanleavegroup <Leave Option>
Change the <GAL Option> to true|false
gam update group <Group Email Address> includeinglobaladdresslist <GAL Option>
Change member to owner or manager as needed
gam update group <Group Email Address> clear member
gam update group <Group Email Address> sync member ou "</Path/To/OU>"
Multiple OUs
gam update group <Group Email Address> sync members ous "'</Path/To/OU/1>','</Path/To/OU/2>'"
The <Role> needs to be specfied as [Member|Manager|Role]
gam update group <Group Email Address> update <Role> <User Email Address>
Add the Owners field to the end of the Google Sheet (or CSV)
gam print groups domain <Your Domain> allfields owners todrive tdtitle "<Your File Name>"
Similarly remove the AllFields option and add owners managers & members or any <GroupFieldName> from this page of the Wiki
gam print groups domain <Your Domain> fields description Owners managers members todrive tdtitle "<Your File Name>"
Create a CSV file for the name description Owners & Members (other fields can be added) where the number of owners is less than or equal to 2. Running this in the Cloud, saves the CSV file in the Downloads folder.
gam config csv_output_row_filter "ownersCount:count<=2" redirect csv <CSV File Name>.csv print groups fields name description Owners Members
Note, when you specify a 'user' field, such as Owners, the output will also automatically include the count of that field, eg OwnersCount.
Show and Print give slightly different outputs. Show will indicate the total number of groups the user is in. This will also work for Member and Manager.
gam user <User Email Address> show groups roles owner
gam user <User Email Address> print groups roles owner
gam user <User Email Address> print groups roles owner todrive
gam print groups matchsetting allowExternalMembers TRUE members memberemailskippattern ".*@<Your Domain>$"
Change the 0 to the value you want to search for. The example below will show groups without any managers and owners.
gam config csv_output_row_drop_filter "'ManagersCount:count>0','OwnersCount:count>0'" print groups managerscount ownerscount todrive
gam update group <Group Email Address> includecustomfooter true customfootertext "<Footer Text>"