GAM group regex

303 views
Skip to first unread message

Gabriel Clifton

unread,
Mar 15, 2021, 7:31:27 PM3/15/21
to GAM for Google Workspace
I am wanting to print some of our groups with some regex, but I really suck at regex. We have a program that creates Google Groups automatically for classes and I am wanting to do some filtering based on that. IE esllab6-0...@domain.com
1. I am wanting to print all groups that do not end in a year which would be all groups not created by that program.
2. Print all groups that do end in a year
3. Disable any group with a year prior to the prior year. IE anything 2019 and before.
Most of the groups that the program created are in our student domain and not our main domain. I have tried gam config csv_output_row_filter "email:regex:^[0-9]+$" print groups todrive and gam config csv_output_row_filter "email:regex:^[0-9]+$@domain.com" print groups todrive
Which both produce nothing. I will be running the third one on a scheduled task so I am thinking programmatically grabbing the year to disable, but can't look for them in the first place.

Gabriel Clifton

unread,
Mar 15, 2021, 8:49:44 PM3/15/21
to GAM for Google Workspace
Thanks Ross!!!
So what we worked out was:
Find all groups with a year at the end. (None of our regular groups end with a four digit number)
gam config csv_output_row_filter "email:regex:^.+[0-9]{4}@domain.com$" redirect csv GroupsWithYear.csv todrive tdlocalcopy print groups
Find all groups without a year at the end.
gam config csv_output_row_drop_filter "email:regex:^.+[0-9]{4}@domain.com$" redirect csv GroupsWithoutYear.csv todrive tdlocalcopy print groups
Find all groups for the year X. Here we did 2017. For testing purposes, we did "info group" instead of "delete group"
gam config csv_input_row_filter "email:regex:^.+20...@domain.com$" redirect stdout deletegroups.log multiprocess redirect stderr stdout csv GroupsWithYear.csv gam info group ~email fields name quick

I am sure I can PowerSmell something to grab years to look at like addyear(-2) for a variable to be inserted into the script each year.


Reply all
Reply to author
Forward
0 new messages