Groups
Add
Manager to Multiple Groups
gam user <Manager Email Address> add groups manager <Group 1 Email Address>,<Group 2 Email Address>,<ETC>
Alias
Create
gam create alias <Alias Email Address> group <Group Email Address>
Delete
gam remove alias <Group Email Address> group <Alias Email Address>
Delete Group(s)
Using CSV
Create a CSV file with just the email addresses of the groups to delete
gam csv <CSV File> gam delete group ~email
User from All Groups
gam user <User Email Address> delete groups
From Users in OU
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
Info
Single Group
gam info group <group name>
Hide Deprecated
Show just the current fields.
gam info group <group name> nodeprecated
CIFields (createtime)
Date a group was created
gam info group <Group Email Address> cifields createtime
Print group(s)
No members
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
No Members, No Managers and No Owners
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
Single Group
gam group <group name> print allfields todrive
To just show the users in the group
gam group <group name> print users fields name
All Groups
gam print groups settings todrive [OR > groups.csv]
All Fields for All Groups in Domain
gam print groups domain <your domain> allfields todrive
Group Members for All Groups in Domain
Add notsuspended to ignore suspended users.
gam print groups members domain <your domain> todrive
Show the Groups which have a specific user
gam print groups member <User Email Address>
Show a list of groups that a user is subscribed to. This works for both internal users and external domains.
gam print groups query memberkey='<user email address inc @Domain>' todrive
Groups a User is a Member of
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
Totalcount
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
Totalcount for All Groups
If totalcount column is zero (0) then indicated an empty group.
gam print groups domain <Your Domain> members managers owners countsonly totalcount todrive
By partial start of Group name
Find groups starting with ...
gam print groups query "email:<Start of Name>*"
Matchsetting
Anyone Can Post
gam print groups domain <domain.com> matchsetting whocanpostmessage anyone_can_post owners todrive
Groups with Collaborative Inbox
gam config csv_output_row_filter "enableCollaborativeInbox:boolean:true" redirect csv ./CollaborativeInboxGroups.csv print groups fields enableCollaborativeInbox todrive
Filter by Setting & Group Name
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
SpamModerationLevel
gam print groups fields spammoderationlevel todrive
Print group-members
Exclude Groups
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
Get Group Members
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
Owners & Managers Only
gam print group-members group <Group Email Address> roles owners,managers
Show the Groups that are Members of Other Groups
gam print group-members types group todrive
Including Sub-Groups
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
Find Groups with Nested Groups
gam print group-members types group todrive
Find Group members including members of Nested Groups
gam print group-members group <Group Email Address> recursive noduplicates todrive
Email Display Pattern
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>"
Exclude Domain Users
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
Suspended Users still in Groups
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
Print GroupList
Users not in Groups
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
Print Messages
Query
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
Update Via JSON file
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
Search
Find Groups with External Members
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
Create
Single Group
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 Groups in Bulk
Create a groups and add teachers as managers so they can add students as required. Hide from the directory.
Create Groups
gam csv <csv file name>.csv gam create group ~email
Add a member, who will become a Manager.
gam csv <csv file name>.csv gam update group ~email add member <Manager Email Address>
Promote User to Manager
gam csv <csv file name>.csv gam update group ~email update manager user <User Email Address>
Prevent External Accounts sending email
gam csv <csv file name>.csv gam update group ~email whocanpostmessage all_in_domain_can_post
Hide the Group from the Gmail directory
gam csv <csv file name>.csv gam update group ~email includeinglobaladdresslist false
Group Owners
List of Groups where the user is the Owner
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
Without Owners
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
Update Group
Single User
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>
From CSV
gam csv <CSV File Name>.csv gam update group <Group Email Address> add member user ~Email
From OU
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>
Change Delivery option for user
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>
Add A User with No Email Delivery option
gam update group <Group Email Address> add member nomail user <User Email Address>
Never Logged In
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
Spam Moderation Level
gam update group <Group Email Address> spam_moderation_level [allow|moderate|silently_moderate|reject]
Remove Members
Single User
gam update group <Group Email Address> delete user <User Email Address>
From CSV
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
Update (Settings)
Who_Can_Post_Message
Other options are allindomaincanpost|allmanagerscanpost|allmemberscanpost|allownerscanpost|anyonecanpost|nonecanpost.
gam update group <Group Email Address> who_can_post_message allownerscanpost
Who_Can_View_Membership
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
Who_Can_View_Group
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
Hide the Group from the Gmail directory
gam update group <Group Email Address> includeinglobaladdresslist false
Turn off Directory Sharing for a Group
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
Update the Delivery & Member settings for Group Members
<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>
Update Multiple Groups for a Single User
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 group users using CSV file
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
Copy Group Settings from another Group
gam csv <student_groups>.csv gam select <student.domain> update group ~group copyfrom <group_with_desired_settings>@student.domain
Suspend a Group| Change Group setting to whocanpostmessage NONE_CAN_POST
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
Ban Users
gam update group <Group Email Address> whoCanBanUsers OWNERS_AND_MANAGERS
Archive Mail for a specific group
gam update group <group email address> isarchived yes
Archive Mail For All Groups
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
Moderate Members
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>
Change the email address of a Group (not tested)
gam update group <current email> email <new email>
Who Can Leave
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>
Include in Global Address List
Change the <GAL Option> to true|false
gam update group <Group Email Address> includeinglobaladdresslist <GAL Option>
Clear (Remove Users)
Change member to owner or manager as needed
gam update group <Group Email Address> clear member
Sync Members from OU
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>'"
Update (Users)
User Role
The <Role> needs to be specfied as [Member|Manager|Role]
gam update group <Group Email Address> update <Role> <User Email Address>
Info about Group Owners, Managers & Members
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.
See the Groups that User is an Owner
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
See Groups with Members outside your Domain and print the users
gam print groups matchsetting allowExternalMembers TRUE members memberemailskippattern ".*@<Your Domain>$"
Count of Managers & Owners
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
CustomFooter
Single Group
gam update group <Group Email Address> includecustomfooter true customfootertext "<Footer Text>"