GAM Command Cheat Sheet

The ultimate reference guide for Google Apps Manager (GAM). Manage users, groups, licenses, and devices from the command line.

What is GAM?

GAM is a command line tool for Google Workspace Agents that allows you to manage many aspects of your domain quickly.

Installation Guide

Choose the version that suits your needs. Standard GAM is great for beginners. Advanced GAM (GAMADV-XTD3) includes extra features for power users.

Standard GAM

Maintained by Jay Lee.

Windows

Download the latest MSI installer:

Download .msi

Mac / Linux / Cloud Shell

Run this command in Terminal:

bash <(curl -s -S -L https://git.io/gam-install)

Advanced GAM

Maintained by Ross Scroggs.

Windows

Download the latest MSI installer:

Download .msi

Mac / Linux / Cloud Shell

Run this command in Terminal:

bash <(curl -s -S -L https://gamadv-xtd3.appspot.com/gam-install.sh)

1. Setup & Diagnostics

  • Check GAM version and connectivity
    gam info domain
  • Check specific user details (Troubleshooting)
    gam info user <user@domain.com>
  • Verify OAuth scopes
    gam oauth info
  • Update GAM to the latest version
    gam update

2. User Management

Creation & Updates

  • Create a user
    gam create user <user@domain.com> firstname "First" lastname "Last" password "initialPassword123"
  • Update user profile (Job, Dept, Manager)
    gam update user <user@domain.com> organizations name "Company" title "Manager" department "Sales" costcenter "CC123"
    gam update user <user@domain.com> relation manager <manager@domain.com>
  • Rename/Move a user (Change Primary Email)
    gam update user <old_email@domain.com> email <new_email@domain.com>
  • Add an alias
    gam create alias <alias@domain.com> user <user@domain.com>

Status & Security

  • Suspend/Unsuspend a user
    gam update user <user@domain.com> suspended on
    gam update user <user@domain.com> suspended off
  • Force password change at next login
    gam update user <user@domain.com> password "newPassword" password_change_required on
  • Reset User Sign-in Cookies (Force Logout)
    gam user <user@domain.com> signout
  • Generate backup codes
    gam user <user@domain.com> update backupcodes
  • Turn off 2SV
    gam user <user@domain.com> turnoff 2sv

3. Group Management

  • Create a group
    gam create group <group@domain.com> name "Group Name" description "Description"
  • Update Group Settings (Access levels)
    gam update group <group@domain.com> who_can_join invited_can_join who_can_view_membership all_in_domain_can_view
  • Add Members/Owners/Managers
    gam update group <group@domain.com> add member <user@domain.com>
    gam update group <group@domain.com> add owner <user@domain.com>
    gam update group <group@domain.com> add manager <user@domain.com>
  • Remove Members
    gam update group <group@domain.com> remove member <user@domain.com>
  • Sync Members from CSV (Overwrite group)
    gam update group <group@domain.com> sync member file members.csv
  • List all groups
    gam print groups

4. Organizational Units (OUs)

  • Create an OU
    gam create org "/Staff/Sales" description "Sales Dept"
  • List all OUs
    gam print orgs
  • Move a user to an OU
    gam update user <user@domain.com> org "/Staff/Sales"
  • Move a Chrome Device to an OU
    gam update cros <device_id> org "/Devices/Kiosk"

5. Mobile & Devices (MDM)

  • List all mobile devices
    gam print mobile
  • List devices for a specific user
    gam user <user@domain.com> print mobile
  • Wipe a mobile device (Account only)
    gam update mobile <resource_id> action account_wipe
  • Block a device
    gam update mobile <resource_id> action block
  • Approve a device (if approval required)
    gam update mobile <resource_id> action approve

6. ChromeOS Devices

  • List all Chrome devices
    gam print cros basic
  • Detailed device list with status
    gam print cros fields serialNumber,status,orgUnitPath,osVersion,lastSync
  • Deprovision a device (Retiring)
    gam update cros <device_id> action deprovision_retiring_device acknowledge_device_touch_requirement
  • Disable/Re-enable
    gam update cros <device_id> action disable
    gam update cros <device_id> action reenable

7. Drive & Files

  • List files owned by a user
    gam user <user@domain.com> print filelist query "mimeType != 'application/vnd.google-apps.folder'"
  • Transfer Drive files (Offboarding)
    gam create datatransfer <old_user@domain.com> gdrive <new_user@domain.com>
  • Add a user as a Writer to a specific file
    gam user <owner@domain.com> add drivefileacl <file_id> user <new_user@domain.com> role writer
  • Empty Trash for a user
    gam user <user@domain.com> empty drivetrash
  • Transfer Ownership (Advanced) Advanced
    gam create datatransfer <old_user> gdrive <new_user> privacy_level shared,private
  • Find Orphaned Files (No Parent Folder) Advanced
    gam user <user> print filelist select orphan true

8. Gmail & Email Settings

  • Set Vacation Responder
    gam user <user@domain.com> vacation on subject "OOO" message "I am out."
  • Create a Forwarding Address
    gam user <user@domain.com> add forwardingaddress <dest@domain.com>
  • Set IMAP/POP settings
    gam user <user@domain.com> pop on imap on
  • Delegate Mailbox
    gam user <user@domain.com> delegate to <delegate@domain.com>
  • Update Signature
    gam user <user@domain.com> signature file sig.html

9. Calendar

  • List user's calendars
    gam user <user@domain.com> print calendars
  • Transfer Calendar Events
    gam create datatransfer <old_user@domain.com> calendar <new_user@domain.com>
  • Add an owner to a resource calendar
    gam calendar <resource_email> add editor <user@domain.com>

10. Licenses

  • Print all licenses
    gam print licenses
  • Assign a license (e.g., Enterprise)
    gam user <user@domain.com> add license 1010020020
  • Remove a license
    gam user <user@domain.com> delete license 1010020020

11. Google Classroom

  • List courses
    gam print courses
  • Create a course
    gam create course name "Math 101" section "A" owner <teacher@domain.com> status ACTIVE
  • Add student/teacher
    gam course <course_id> add student <student@domain.com>
    gam course <course_id> add teacher <teacher@domain.com>
  • Sync students from CSV
    gam course <course_id> sync students file students.csv

12. Resources (Buildings & Rooms)

  • Create a Building
    gam create building "Building A" floor "1" coordinates "-33.85,151.21"
  • Create a Calendar Resource (Room)
    gam create resource name "Conf Room 1" type "Conference Room" building "Building A" capacity 10
  • List Resources
    gam print resources

13. Reports

  • User Activity Report
    gam report user start 2023-01-01 end 2023-01-31
  • Admin Activity Report
    gam report admin event USER_SETTINGS

14. Shared Drives (Team Drives) Advanced

  • Create a Shared Drive
    gam create teamdrive "HR Files"
  • Add Members (Manager, Content Manager, Contributor)
    gam update teamdrive "HR Files" add member <user@domain.com> role manager
    gam update teamdrive "HR Files" add member <user@domain.com> role organizer
  • List all Shared Drives
    gam print teamdrives
  • Manage Settings (Prevent external sharing)
    gam update teamdrive "HR Files" teamdriveaclchecks false

15. Contacts & People Advanced

  • Update a user's PROFILE photo
    gam user <user@domain.com> update photo file photo.jpg
  • List Directory Contacts
    gam print contacts
  • Clear a user's personal contacts
    gam user <user@domain.com> clear contacts

16. Google Vault Advanced

  • List Matters
    gam print matters
  • Create a Hold (Mail)
    gam create hold matter <matter_id> name "Investigation 1" corpus mail accounts <user@domain.com>
  • Export Search Results
    gam create export matter <matter_id> name "Export 1"

17. Advanced Security Advanced

  • Print Application Specific Passwords (ASPs)
    gam print asps
  • Revoke all user tokens (Kick off all devices)
    gam user <user@domain.com> delete tokens
  • Check 2SV Enforcement Status (Ou-based)
    gam print orgs fields name,2sv_enrollment

18. Advanced Bulk Operations

GAMADV-XTD3 allows multi-threaded batch processing for huge speed gains.

Standard CSV (Sequential)

Best for under 1000 users.

gam csv data.csv gam update user ~user suspended on

Batch Processing (Multi-threaded) Advanced

Best for 10,000+ users. Runs multiple commands at once.

gam csv data.csv gam tbatch update user ~user suspended on
Tip: Use gam config num_threads 20 save to increase the number of parallel threads.

19. Exporting Data to CSV (Expanded)

GAM allows you to export almost any list to a CSV file. This is crucial for reporting and auditing.

  • Export all users
    gam print users > all_users.csv
  • Export all users with ALL fields (Detailed) Advanced
    gam print users allfields > users_detailed.csv
  • Export drive file ACLs (Permissions) Advanced
    gam all users print filelist fields id,name,permissions > permissions.csv
  • Export all groups
    gam print groups > all_groups.csv
  • Export all members of all groups
    gam print group-members > group_members.csv
  • Export all licenses assigned
    gam print licenses > licenses.csv

Bulk Operations Tip

One of GAM's most powerful features is bulk operations via CSV.

  1. Create a CSV file (e.g., data.csv) with a header (e.g., user).
  2. Run command:
    gam csv data.csv gam update user ~user suspended on

The ~user syntax pulls the value from the "user" column in the CSV for each row.