Patronum Logo
00%
Patronum Logo
menu-icon

How to Automate Google Workspace Offboarding: 4 Methods Compared

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).

Planned exit or urgent exit?

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.

What does offboarding automation have to get right?

For a planned exit, Google’s rules for suspended accounts set the order:

  • Mail stops. Suspension blocks new email and calendar invitations, and suspended accounts are still charged at the same rate as active ones (Google).
  • Secondary calendars follow their owner. Google is rolling out a change that suspends and deletes secondary calendars with their owner; ownership must move first (Google Workspace Updates).
  • Files need a live recipient. Drive files can only move to an active account (Google).
  • Sign-out isn’t the end. With third-party SSO, Google warns the SSO session may still allow access (Google).

The baseline and 4 methods at a glance

ApproachWhat starts itWhat it automatesWhat’s still yoursCost
Baseline: Admin consoleAn adminDrive, primary Calendar and Data Studio transfer at deletionEvery other stepIncluded
1. GAM7You run a scriptCredential cleanup (sign-out only with its signout option), Drive, groups, rename, aliases, suspensionWriting, testing and checking itFree, open source
2. Apps Script + Admin SDKA trigger you writeSuspension, OU moves, groups; Drive files and qualifying primary-calendar eventsCode, errors, quotas, secondary calendarsStaff time
3. Okta or Entra IDThe leaver’s status in your IdPSuspends the Google accountFiles, calendars, groups, mail, licenses, holdsYour IdP subscription
4. No-code policy (Patronum)Scope plus a condition (Suspended, End Date); hourly by default, not for urgent containmentDrive, calendars, groups, contacts, mail routing, license, roles; email archiveBuilding and testing the policyBase plan $8 per user per year; Archive extra ($2 per archived account per year, per Patronum’s FAQ) plus Cloud Storage

Baseline: the Admin console

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.

Method 1: GAM7 scripts

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.

PurposeReference syntaxCheck before the next step
Remove credentials; sign outgam user <UserItem> deprovision signoutBackup codes fail on a suspended account
Transfer Drive filesgam user <UserItem> transfer drive <UserItem> (Drive Transfer)All but trashed files move by default; confirm it finished
Remove group membershipsgam user <UserItem> delete groups (Group Membership)No memberships remain
Rename to free the addressgam update user <UserItem> email <EmailAddress> (Users)The old address is now an alias
Release the old addressgam delete alias <EmailAddressEntity> (Aliases)Alias gone before assigning the address to a Group
Suspendgam 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.

Method 2: Apps Script with the Admin SDK

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.

Method 3: Identity-provider deprovisioning (Okta, Entra ID)

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.

Method 4: A no-code offboarding policy (Patronum)

Offboarding is in both Patronum plans, including the $8 base plan (Patronum Help):

  1. Set the scope. Base a Directory policy on all users, an OU (often an offboarding OU) or a Google Group, filtered on Suspended, End Date or Last Sign In (Patronum Help).
  2. Name the people. An Executor receives the data; Approval and Notify users approve and hear about the run.
  3. Choose the actions. Files to the executor or into a Shared Drive, calendars, groups, contacts, license, roles and Chat Spaces. To archive mail, connect a Google Cloud Storage bucket under Settings > Integrations (Patronum Help).
  4. Preview. PREVIEW lists the users the policy targets, from directory data cached hourly (Patronum Help). It shows who is in scope, not an execution simulation.
  5. Test, then activate. Scope the policy to a test account first. Once activated, it runs hourly by default (first run within 60 minutes) or daily, weekly or monthly; policies affecting more than 80% of users need approval (Patronum Help).
  6. Check the log. Logs show whether each action succeeded (Patronum Help).
Patronum policy Conditions step with the Attribute list open, showing Start Date, End Date and Archived, and the PREVIEW button
A Patronum policy’s Conditions step with the Attribute list open. End Date is one of the attributes; Suspended sits further down the same list. PREVIEW shows which users match.

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.

How should the automation handle the leaver’s mail?

These routes solve different problems; test yours on a test account first:

  • Forward, while the account stays active. Gmail forwards new messages except spam once the receiving address confirms (Gmail Help). It stops helping at suspension. In Patronum, an internal forwarding address is added immediately; an external one must approve (Patronum Help).
  • Move the address to a Group. Renaming the user leaves the old address as an alias on the renamed account (Google), and only one account can use an alias (Google). Delete that alias, assign the address to the Group, then check its delivery and external-posting settings. Patronum’s policy uses Rename User and Assign Group (Patronum Help).
  • Delegate or transfer the old mail. Delegation works while the account is active; email transfer copies existing mail to another account. Neither keeps new mail arriving after suspension. See Gmail delegation and transferring a former employee’s email.

Which method should you choose?

  • A few leavers a year: the Admin console and a checklist.
  • A confident scripter on staff: GAM7 or Apps Script; you own the code.
  • Okta or Entra ID in place: let it suspend, then add a handover method.
  • No scripting, same handover every time: a no-code policy such as Patronum.

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.

FAQ

Does freeing a leaver’s license cut my Google bill?

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).

Can Okta or Entra ID trigger a Patronum offboarding policy?

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.

Sources