您可以使用 Admin SDK Groups Settings 服務,在 Apps Script 中使用 Admin SDK 的 Groups Settings API。這個 API 可讓 Google Workspace 網域管理員 (包括經銷商) 管理 Google Workspace 帳戶中群組的群組設定。
參考資料
如要進一步瞭解這項服務,請參閱 Admin SDK Groups Settings API 的參考文件。與 Apps Script 中的所有進階服務一樣,Admin SDK Groups Settings 服務使用的物件、方法和參數,都與公開 API 相同。詳情請參閱「如何判斷方法簽章」。
/** * Gets a group's settings and logs them to the console. */functiongetGroupSettings(){// TODO (developer) - Replace groupId value with yoursconstgroupId='exampleGroup@example.com';try{constgroup=AdminGroupsSettings.Groups.get(groupId);console.log(JSON.stringify(group,null,2));}catch(err){// TODO (developer)- Handle exception from the APIconsole.log('Failed with error %s',err.message);}}
/** * Updates group's settings. Here, the description is modified, but various * other settings can be changed in the same way. * @see https://developers.google.com/admin-sdk/groups-settings/v1/reference/groups/patch */functionupdateGroupSettings(){constgroupId='exampleGroup@example.com';try{constgroup=AdminGroupsSettings.newGroups();group.description='Newly changed group description';AdminGroupsSettings.Groups.patch(group,groupId);}catch(err){// TODO (developer)- Handle exception from the APIconsole.log('Failed with error %s',err.message);}}