How to export Google Groups and their members with GAM

One GAM7 command exports every group in your domain with its members, one row per membership. Here is the command, how to expand nested groups into the people inside them, and which of the two exports to keep.

A list of groups tells you names. A membership export tells you who can reach what. It is the first thing to pull before a cleanup, an audit, or a new technology director's first week, and the thing you will wish you had pulled before any group was deleted.

The short answer

gam print group-members

That prints one row per membership, across every group in the domain. To send it to a Google Sheet instead of the screen:

gam print group-members todrive

Groups inside groups

A group can be a member of another group, and by default the export leaves it that way. The GAM documentation: "By default, members that are groups are displayed as a single entry of type GROUP". (GAM wiki: Groups Membership) To expand those rows into the people inside them:

gam print group-members recursive noduplicates

The recursive option, in the documentation's words, "recursively expands group members to display their user members."

Which one to keep

Keep both, because they answer different questions.

The plain export records the direct membership structure: which groups contain which other groups. The expanded export throws that nesting away, so it cannot give the shape back to you. Rebuilding a deleted group takes more than its members, though. Its settings, aliases and posting permissions go with it, which is why the cleanup guide starts with a fuller export than this one.

The recursive export records the people: everyone who actually receives a group's mail and inherits what was shared to it. That is the one to read when the question is "who can see this folder?"

Just the owners

To see who owns each group, filter by role:

gam print group-members roles owner

Groups with no owner at all will not appear in that list, which makes it a quick way to spot the ones nobody is responsible for: compare it against your full list of groups.

Sources


In ORINEX Workspace, the Groups page exports every group with its member count in one click, and each group's own page lists its members. What ORINEX Workspace does.