Had a need to add all the users from a GSuite group as editors on a Google Calendar. The script reads and outputs the current ACLs, gets the members of the group and then adds them to the calendar giving them the appropriate permissions. At the end, it outputs the new permissions.

Different permissions can be given freebusy|read|editor|owner by changing the permission on line #23

#- Address of google calendar to add permissions to -#
$calendarAddress = "[email protected]"

#- Address of the group containing the users -#
$groupForAccess  = "[email protected]"

#-- read the acl of the calendar --#
.\gam.exe calendar $calendarAddress showacl

#-- get the group members --#
.\gam.exe print group-members group $groupForAccess > CSVs\group.csv

#-- load in the CSV --#
$list = Import-Csv CSVs\group.csv

#-- for each member --#
foreach ($entry in $list){

    #-- output who we're on --#
    echo "add $($entry.email) `r`n"

    #-- add the user to the calendar --#
    .\gam.exe calendar $calendarAddress add editor $entry.email

}

#-- read new permissions --#
.\gam.exe calendar $calendarAddress showacl

The users receive an email from Google telling them that the user who GAM is authenticated as has added them to the group.


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.