How to Automate Google Workspace Offboarding: 4 Methods Compared
By Patronum
November 27, 2026
Read Time: 7 mins

By Patronum
November 27, 2026
Read Time: 7 mins

Google Workspace doesn’t document a rule-based offboarding workflow, so teams automate it four ways: GAM7 scripts, Apps Script with the Admin SDK, deprovisioning from Okta or Entra ID, or a no-code policy tool, with the Admin console as the manual baseline. Identity providers handle the account; handing over files, calendars, groups and mail needs a script or a tool.
Patronum automates Google Workspace offboarding with a policy: when a user matches its scope and a condition such as Suspended or End Date, it transfers their files and calendars, removes groups, routes their email and changes the license when the policy next runs (hourly by default).
This page covers planned departures. For a planned departure, arrange secondary-calendar ownership before suspension. For an urgent departure, contain access immediately and use a separately verified recovery and handover procedure; our immediate offboarding guide covers that order. Scheduled automation, including an hourly policy, isn’t an urgent-containment mechanism. For the full manual checklist, see the Google Workspace offboarding guide.
For a planned exit, Google’s rules for suspended accounts set the order:
| Approach | What starts it | What it automates | What’s still yours | Cost |
|---|---|---|---|---|
| Baseline: Admin console | An admin | Drive, primary Calendar and Data Studio transfer at deletion | Every other step | Included |
| 1. GAM7 | You run a script | Credential cleanup (sign-out only with its signout option), Drive, groups, rename, aliases, suspension | Writing, testing and checking it | Free, open source |
| 2. Apps Script + Admin SDK | A trigger you write | Suspension, OU moves, groups; Drive files and qualifying primary-calendar events | Code, errors, quotas, secondary calendars | Staff time |
| 3. Okta or Entra ID | The leaver’s status in your IdP | Suspends the Google account | Files, calendars, groups, mail, licenses, holds | Your IdP subscription |
| 4. No-code policy (Patronum) | Scope plus a condition (Suspended, End Date); hourly by default, not for urgent containment | Drive, calendars, groups, contacts, mail routing, license, roles; email archive | Building and testing the policy | Base plan $8 per user per year; Archive extra ($2 per archived account per year, per Patronum’s FAQ) plus Cloud Storage |
When a super admin deletes a user, Google can transfer their Drive and Docs files, primary Calendar data and Data Studio data. Untransferred data is deleted, and Vault retention rules and holds stop applying (Google). Bulk Drive transfers that run longer than 36 hours stop and must be restarted (Google).
Groups, secondary calendars, mail, devices and licenses stay manual; use the employee offboarding checklist.
GAM7 is “a free, open source command line tool for Google Workspace Administrators” (GAM7 wiki). GAM’s deprovision command removes specified credentials; include its signout option when sign-out is required (GAM7 wiki: Deprovision). The following is command-reference syntax, not a complete offboarding script; we haven’t run it, and angle brackets are placeholders.
| Purpose | Reference syntax | Check before the next step |
|---|---|---|
| Remove credentials; sign out | gam user <UserItem> deprovision signout | Backup codes fail on a suspended account |
| Transfer Drive files | gam user <UserItem> transfer drive <UserItem> (Drive Transfer) | All but trashed files move by default; confirm it finished |
| Remove group memberships | gam user <UserItem> delete groups (Group Membership) | No memberships remain |
| Rename to free the address | gam update user <UserItem> email <EmailAddress> (Users) | The old address is now an alias |
| Release the old address | gam delete alias <EmailAddressEntity> (Aliases) | Alias gone before assigning the address to a Group |
| Suspend | gam suspend user <UserItem> (Users) | Sign-in is blocked |
Calendars, Group creation and error handling aren’t covered. For a planned exit, clean up credentials before suspension: on a suspended account the wiki shows “You must unsuspend to process backupcodes”. For an urgent exit, contain access first and treat cleanup as a separate, verified step.
Not keen to own a script? See GAM alternatives or the GAM7 commands cheat sheet.
Apps Script’s Admin SDK Directory service lets admins “manage devices, groups, users, and other entities” (Google). For offboarding, that means setting a user’s suspended field or orgUnitPath (Directory API). Handover goes through the separate Data Transfer API, with two limits (Google). Calendar transfer covers only future, non-private primary-calendar events with at least one guest or resource, not every calendar. For Drive, omitting the privacy setting transfers shared files only; specify PRIVATE and SHARED to move everything.
The appeal is triggers, such as a row in an HR sheet, but each execution stops at 6 minutes, and triggers get 6 hours of total runtime a day (Apps Script quotas), so plan for partial runs.
With deprovisioning on and no deactivation option selected, Okta suspends the user in Okta and in Google (Okta), stopping short of deletion so admins can clean up (Okta). In Entra ID, removing a user from the sync scope disables them in Google without deleting them, and the sync cycle runs every 40 minutes (Microsoft Learn).
Neither connector moves files, calendars or mail. A common pattern: the IdP suspends the account, then a Patronum policy filtered on Suspended runs the handover on its next cycle. Because that runs after suspension, arrange secondary-calendar ownership before the IdP suspends the account. Details in Okta and Entra deprovisioning for Google Workspace.
Offboarding is in both Patronum plans, including the $8 base plan (Patronum Help):

For fixed-term staff, set the End Date on the profile; see offboarding contractors on an end date. For an urgent exit, contain access first; Emergency Offboard can then run your offboarding policy against one user outside its criteria (Patronum Help).
Patronum Archive moves a leaver’s email, including supported email exported from Vault, to your own Google Cloud Storage bucket; it doesn’t cover Drive or Chat (Patronum Archive). Its FAQ says Archive is part of standard Patronum, charged $2 per year per archived account; Google Cloud bills the storage. Remove an Archived User license only once the records you must keep, and their retention arrangement, are preserved.
These routes solve different problems; test yours on a test account first:
Whichever you choose, offboard a test user with Drive files, a secondary calendar and two groups, then confirm sign-in, files, calendar, groups, mail and license.
On the Flexible Plan you can remove users at any time and the next monthly payment drops. On the Annual/Fixed-Term Plan you can remove accounts during the term, but reducing committed seats generally waits until renewal; until then, you pay for the licenses you committed to (Google).
The documented pattern here uses Google account state and scheduled policy evaluation; direct IdP event triggering has not been established in the reviewed sources.
For the same handover every time without scripts, build one Patronum offboarding policy in the 30-day free trial and test it on a test account. See Patronum’s onboarding and offboarding automation.