Duplicate a group with along with all members

1,111 views
Skip to first unread message

Jeff

unread,
Sep 7, 2021, 7:40:41 PM9/7/21
to GAM for Google Workspace
I need to clone a group again- sorry I can't recall how to get all the members to come over as well:

gam create group gro...@mydomain.com copyfrom group_1

this works but does not copy the members.

THANKS!

Ross Scroggs

unread,
Sep 7, 2021, 7:55:17 PM9/7/21
to google-ap...@googlegroups.com
Jeff,


gam redirect csv GroupMembers.csv print group-members group gro...@mydomain.com
Edit GroupMembers.csv and replace gro...@mydomain.com with gro...@mydomain.com
gam redirect stdout ./Group2Updates.txt redirect stderr stdout update group csvkmd GroupMembers.csv keyfield group subkeyfield role datafield email sync csvdata email

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/f0718674-a72a-4b20-b973-38bf43103ce4n%40googlegroups.com.


--

Jeff Sararas

unread,
Sep 8, 2021, 12:51:36 PM9/8/21
to google-ap...@googlegroups.com

Thanks Ross- It appears to run, but the CSV is empty. I’ve tried to run the command with the CSV file open and with it closed. There are 8 members in the group. I’m running an old version 5.35.03 could that be an issue?

 

 

 

 

 

 

Jeff Sararas | Data and Technology Specialist

TAG Hardware

T:  (604)542.4888 (ext 115)

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/OzYAnjzhwl0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/CAJkvRS_5Xv6EjF0tpmRdZOnp%3DN96WTP2q4Te_6QLh796BLAs2A%40mail.gmail.com.

Chris River

unread,
Sep 8, 2021, 3:43:31 PM9/8/21
to GAM for Google Workspace
Updating GAM might help. I think I've seen that issue before, but I could easily be misremembering.

If you'd like a one-liner to do this for a single group, this should get you there (replace sourcegroup@domain and newgroup@domain with your source and destination groups' names):
gam print group-members group sourcegroup@domain | ConvertFrom-Csv | select *,@{n="destgroup";e={"newgroup@domain"}} | ConvertTo-Csv | gam redirect csv ./NewGroupUpdates.csv append update group csvkmd - keyfield destgroup subkeyfield role datafield email sync preview actioncsv csvdata email

That will just generate a preview CSV of the changes that GAM would make, so you can verify before running. Just remove "preview" from that command to have it actually perform the sync.

This does the same thing as Ross' command, except that it creates a new column with the new group name for you (without requiring manual CSV editing), and it uses the very handy "actioncsv" parameter to output the results of the command to csv format for easier review. csvkmd only operates single-threaded (unless Ross has a way to multithread it that I haven't worked out yet), but of course that's not an issue for only 8 members.

Jeff Sararas

unread,
Sep 8, 2021, 3:47:18 PM9/8/21
to google-ap...@googlegroups.com

Thanks a lot Chris!

 

Jeff

 

From: google-ap...@googlegroups.com <google-ap...@googlegroups.com> On Behalf Of Chris River
Sent: September 8, 2021 12:44 PM
To: GAM for Google Workspace <google-ap...@googlegroups.com>
Subject: Re: [GAM] Duplicate a group with along with all members

 

Updating GAM might help. I think I've seen that issue before, but I could easily be misremembering.

 

If you'd like a one-liner to do this for a single group, this should get you there (replace sourcegroup@domain and newgroup@domain with your source and destination groups' names):

gam print group-members group sourcegroup@domain | ConvertFrom-Csv | select *,@{n="destgroup";e={"newgroup@domain"}} | ConvertTo-Csv | gam redirect csv ./NewGroupUpdates.csv append update group csvkmd - keyfield destgroup subkeyfield role datafield email sync preview actioncsv csvdata email

 

That will just generate a preview CSV of the changes that GAM would make, so you can verify before running. Just remove "preview" from that command to have it actually perform the sync.

 

This does the same thing as Ross' command, except that it creates a new column with the new group name for you (without requiring manual CSV editing), and it uses the very handy "actioncsv" parameter to output the results of the command to csv format for easier review. csvkmd only operates single-threaded (unless Ross has a way to multithread it that I haven't worked out yet), but of course that's not an issue for only 8 members.

On Wednesday, September 8, 2021 at 12:51:36 PM UTC-4 Jeff wrote:

Thanks Ross- It appears to run, but the CSV is empty. I’ve tried to run the command with the CSV file open and with it closed. There are 8 members in the group. I’m running an old version 5.35.03 could that be an issue?

 

 

Image removed by sender.

 

 

Image removed by sender.

Reply all
Reply to author
Forward
0 new messages