delete all posts (discussions) in groups

1,319 views
Skip to first unread message

Donato Giano

unread,
Sep 11, 2022, 10:19:16 AM9/11/22
to GAM for Google Workspace
Hello everyone,
I have a set of groups and I would like to delete all the posts in them from the groups so that I can reset them each time the school year changes but I can't figure it out and am forced to delete them by hand, can anyone help me?

Thank you all,
Donato

Jay Lee

unread,
Sep 11, 2022, 10:31:08 AM9/11/22
to google-ap...@googlegroups.com
There's no API to delete the posts alone but you could try just deleting and recreating the groups themselves.

Jay

--
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/c12c3411-8ecf-4562-95e0-bff2931e12ffn%40googlegroups.com.

Donato Giano

unread,
Sep 11, 2022, 12:11:00 PM9/11/22
to GAM for Google Workspace
how could I do to export all of them with their settings and recreate them, could you give me some pointers using csv files, thanks again

Donato

Adam Johnson

unread,
Sep 12, 2022, 8:28:45 AM9/12/22
to GAM for Google Workspace
I've only retrieved the settings of groups using gam, not created any (was working on a migration out of Google Workspace into M365), but I was using:

gam print groups query "email=<groupemailaddress>" allfields

I didn't spend much time on figuring out how to get a gam csv command to do that query for each group of a csv file - my memory was that the query in quotes didn't seem to expand the ~email, but I may have had some other piece of the puzzle wrong, and I was writing this as part of a larger PowerShell script,  so I just used created a file with that line of code once per group, then used gam batch to run the lines in parallel and send the output to a file:

Powershell, with the list of groups in $ourGroups - each list entry in which had the email address in the property called "email":

$ourGroups | ForEach-Object { "gam print groups query ""email=$($_.email)"" allfields"} | Out-File -Encoding utf8 -FilePath GamPrintGroupsQueryBatch.txt


Running that ouput via gam:

gam redirect csv .\GoogleGroupsSettings.csv multiprocess batch GamPrintGroupsQueryBatch.txt


If I remember correctly, the query can also use "email:addressprefix*"  - note the colon instead of equals sign, and the star to denote "addresses that start with" - if the groups you want to change all share a common prefix, that would get you the settings in one command.

Donato Giano

unread,
Sep 13, 2022, 10:14:33 AM9/13/22
to GAM for Google Workspace
Thank you very much

Adam Johnson

unread,
Sep 13, 2022, 12:27:14 PM9/13/22
to GAM for Google Workspace
So, something I just discovered from the project I was working on about:

gam print groups query ""email=$($_.email)"" allfields

It appears that the above query is case sensitive in regards to the email address.
However, the results of that query (and any other I've found that returns Google Groups email addresses) returns the group email address in all lower-case.

This means that when I took a list of all users in our top-level OrgUnit, and listed all the groups those users were members of, and sorted those group emails with the -Unique option to remove duplicate group email addresses, then fed that list of (all lower case) group emails through the above query, it failed to find the settings on any groups which had upper-case letters in the email address.

Not sure how I could FIND those groups' correct case-sensitive names, other than looking in the Admin console manually (not gonna happen for over 500 groups) so I looked for another way.

The query parameter can take "email:<emailStartsWithString>*" with a colon instead of an equals-sign, and ending with an asterisk  - this query is NOT case sensitive, and I figured if I put the full email address with the asterisk appended, I should only find the one group, since we never registered ourdomain.com.ourdomain.com as a domain in our Google tenant ;)

Gotta say, that one went un-noticed for over a week - no errors in the logs, since a query that returns zero results is not actually an error condition. 

It also blew my mind that 
gam info group <emailaddress> 
returns lower case, regardless of what mixture of upper/lower case I put in the email address, when that's not the case stored in the system, and that there would be any query that would be case sensitive when all results seem to actively lower-case the addresses before returning them.

Ross Scroggs

unread,
Sep 13, 2022, 12:57:03 PM9/13/22
to google-ap...@googlegroups.com
Adam,

With Advanced GAM you can do the following;

gam redirect csv ./RootOUUserGroups.csv ou / print groups

gam redirect stderr - multiprocess redirect csv ./RootOUUserGroupSettings.csv print groups select csvfile RootOUUserGroups.csv:Group allfields


Ross




--

Adam Johnson

unread,
Sep 23, 2022, 6:42:37 PM9/23/22
to GAM for Google Workspace
Ross, once again, it's awsome to have such a helpfully responsive developer available just for posting here.

I did notice something about this method:

gam redirect stderr - multiprocess redirect csv ./RootOUUserGroupSettings.csv print groups select csvfile RootOUUserGroups.csv:Group allfields

that also surprised me - it seems to grab 40 or so lines from the input CSV file for each worker thread.  I'd bumped up the threads in my .ini file to 15, which was about as high as I could go before running into "Queries per minute per user" API limits, but I hit them with this line pretty quickly.  It worked thru the 16-second backoffs and completed anyway, so it's fine, just surprised me.

Ross Scroggs

unread,
Sep 23, 2022, 7:21:23 PM9/23/22
to google-ap...@googlegroups.com
Adam,

"it seems to grab 40 or so lines from the input CSV file for each worker thread"
It would have read the entire CSV file and then processed them serially; no worker threads involved.

Ross



--
Reply all
Reply to author
Forward
0 new messages