Install Google GAM
if (!(Get-Command choco.exe -ErrorAction SilentlyContinue)) {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))}

# Defining $ENV:ChocotaleyInstall so that it would be called by refreshenv
$ENV:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.."
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
choco install gam -y
GAM Commands

(source: https://sites.google.com/jis.edu.bn/gam-commands/people/groups#h.p_nntEbEGomn0L)

Get Domain Information

PS C:\Windows\system32> gam info domain
Customer ID: fjasoigaroineafo
Primary Domain: kimconnect.com
Primary Domain Verified: True
Customer Creation Time: 1700-32-15T23:23:29.167000Z
Default Language: en

Get a list of all users

PS C:\Windows\system32> gam print users allfields todrive
Getting all Users in G Suite account (may take some time on a large account)...
Got 9999 Users: [email protected] - [email protected]

Add user

[email protected]
game create user $user

Join user to Group

gam update group [email protected] add members users "brucelee miketyson"

Get members of Group

gam.exe print group-members group_ns "[email protected]"
 

Reset user’s password and force change on next login

$username='[email protected]'
$genericPassword='j5JW$KLQJ0ij.$Afjajf3ji90ajfwij930ar0weijfijjui0vja'
gam update user $username password $genericPassword changepassword on

Suspend users

$username='[email protected]'
gam update user $username suspended on

----- Disable all users inside the Disabled Account OU -----
gam print users query "orgUnitPath='/DisabledAccounts'" | gam csv - gam update user ~primaryEmail suspended on

Finish previous commands before proceeding with ‘commit-batch’

gam create user [email protected]
gam create user [email protected]
gam create user [email protected]
commit-batch
gam update group [email protected] add members users "mike.tyson bruce.lee"

Turn on imap for ALL users

gam all users imap on

Change user’s password according to a CSV list

$passwordFile='c:\scripts\passwords.csv'
gam csv $passwordFile gam update user ~Email password ~Password

Calling a batch file

gam batch c:\scripts\create-users.txt
Find file name or file owner with file name/id
 
$fileName='DevOps Schedule'
gam user '[email protected]' show filelist query "title = '$fileName'"

Print all Orgs

PS C:\Windows\system32> gam print orgs
Getting all Organizational Units in G Suite account (may take some time on a large account)...
orgUnitPath,orgUnitId,name,parentOrgUnitId

PS C:\Windows\system32> gam print domains
domainName,verified,creationTime,type,parentDomainName

List all users who have not logon in X months

$monthsAgo=12
$dateString=(get-date).AddMonths(-$monthsAgo).tostring("yyyy-MM-ddT00:00:00.000Z")
gam report users filter "accounts:last_login_time<$dateString" todrive

Report of Users vs Storage Quotas – Saving to Google Drive

gam report users parameters accounts:drive_used_quota_in_mb,accounts:gmail_used_quota_in_mb,accounts:used_quota_in_mb,accounts:total_quota_in_mb,accounts:used_quota_in_percentage todrive

All Google GAM Parameters as of May 2020

PS C:\Windows\system32> gam report usageparameters user
parameter
accounts:admin_set_name
accounts:creation_time
accounts:disabled_reason
accounts:drive_used_quota_in_mb
accounts:first_name
accounts:gmail_used_quota_in_mb
accounts:gplus_photos_used_quota_in_mb
accounts:is_2sv_enforced
accounts:is_2sv_enrolled
accounts:is_archived
accounts:is_delegated_admin
accounts:is_disabled
accounts:is_less_secure_apps_access_allowed
accounts:is_super_admin
accounts:is_suspended
accounts:last_login_time
accounts:last_name
accounts:last_sso_time
accounts:num_authorized_apps
accounts:num_roles_assigned
accounts:num_security_keys
accounts:password_length_compliance
accounts:password_strength
accounts:total_quota_in_mb
accounts:used_quota_in_mb
accounts:used_quota_in_percentage
accounts:user_has_overridden_name
classroom:last_interaction_time
classroom:num_courses_created
classroom:num_posts_created
docs:num_owned_google_documents_created
docs:num_owned_google_documents_edited
docs:num_owned_google_documents_trashed
docs:num_owned_google_documents_viewed
docs:num_owned_google_drawings_created
docs:num_owned_google_drawings_edited
docs:num_owned_google_drawings_trashed
docs:num_owned_google_drawings_viewed
docs:num_owned_google_forms_created
docs:num_owned_google_forms_edited
docs:num_owned_google_forms_trashed
docs:num_owned_google_forms_viewed
docs:num_owned_google_presentations_created
docs:num_owned_google_presentations_edited
docs:num_owned_google_presentations_trashed
docs:num_owned_google_presentations_viewed
docs:num_owned_google_spreadsheets_created
docs:num_owned_google_spreadsheets_edited
docs:num_owned_google_spreadsheets_trashed
docs:num_owned_google_spreadsheets_viewed
docs:num_owned_items_created
docs:num_owned_items_edited
docs:num_owned_items_trashed
docs:num_owned_items_viewed
docs:num_owned_other_types_created
docs:num_owned_other_types_edited
docs:num_owned_other_types_trashed
docs:num_owned_other_types_viewed
drive:num_google_documents_created
drive:num_google_documents_edited
drive:num_google_documents_trashed
drive:num_google_documents_viewed
drive:num_google_drawings_created
drive:num_google_drawings_edited
drive:num_google_drawings_trashed
drive:num_google_drawings_viewed
drive:num_google_forms_created
drive:num_google_forms_edited
drive:num_google_forms_trashed
drive:num_google_forms_viewed
drive:num_google_presentations_created
drive:num_google_presentations_edited
drive:num_google_presentations_trashed
drive:num_google_presentations_viewed
drive:num_google_sites_created
drive:num_google_sites_edited
drive:num_google_sites_trashed
drive:num_google_sites_viewed
drive:num_google_spreadsheets_created
drive:num_google_spreadsheets_edited
drive:num_google_spreadsheets_trashed
drive:num_google_spreadsheets_viewed
drive:num_items_created
drive:num_items_edited
drive:num_items_trashed
drive:num_items_viewed
drive:num_other_types_created
drive:num_other_types_edited
drive:num_other_types_trashed
drive:num_other_types_viewed
drive:num_owned_external_items_added
drive:num_owned_external_items_delta
drive:num_owned_external_items_removed
drive:num_owned_google_documents_added
drive:num_owned_google_documents_created
drive:num_owned_google_documents_delta
drive:num_owned_google_documents_edited
drive:num_owned_google_documents_removed
drive:num_owned_google_documents_trashed
drive:num_owned_google_documents_viewed
drive:num_owned_google_drawings_added
drive:num_owned_google_drawings_created
drive:num_owned_google_drawings_delta
drive:num_owned_google_drawings_edited
drive:num_owned_google_drawings_removed
drive:num_owned_google_drawings_trashed
drive:num_owned_google_drawings_viewed
drive:num_owned_google_forms_added
drive:num_owned_google_forms_created
drive:num_owned_google_forms_delta
drive:num_owned_google_forms_edited
drive:num_owned_google_forms_removed
drive:num_owned_google_forms_trashed
drive:num_owned_google_forms_viewed
drive:num_owned_google_presentations_added
drive:num_owned_google_presentations_created
drive:num_owned_google_presentations_delta
drive:num_owned_google_presentations_edited
drive:num_owned_google_presentations_removed
drive:num_owned_google_presentations_trashed
drive:num_owned_google_presentations_viewed
drive:num_owned_google_sites_added
drive:num_owned_google_sites_created
drive:num_owned_google_sites_delta
drive:num_owned_google_sites_edited
drive:num_owned_google_sites_removed
drive:num_owned_google_sites_trashed
drive:num_owned_google_sites_viewed
drive:num_owned_google_spreadsheets_added
drive:num_owned_google_spreadsheets_created
drive:num_owned_google_spreadsheets_delta
drive:num_owned_google_spreadsheets_edited
drive:num_owned_google_spreadsheets_removed
drive:num_owned_google_spreadsheets_trashed
drive:num_owned_google_spreadsheets_viewed
drive:num_owned_internal_items_added
drive:num_owned_internal_items_delta
drive:num_owned_internal_items_removed
drive:num_owned_items_added
drive:num_owned_items_created
drive:num_owned_items_delta
drive:num_owned_items_edited
drive:num_owned_items_removed
drive:num_owned_items_trashed
drive:num_owned_items_viewed
drive:num_owned_items_with_visibility_anyone_in_domain_added
drive:num_owned_items_with_visibility_anyone_in_domain_delta
drive:num_owned_items_with_visibility_anyone_in_domain_removed
drive:num_owned_items_with_visibility_anyone_in_domain_with_link_added
drive:num_owned_items_with_visibility_anyone_in_domain_with_link_delta
drive:num_owned_items_with_visibility_anyone_in_domain_with_link_removed
drive:num_owned_items_with_visibility_anyone_with_link_added
drive:num_owned_items_with_visibility_anyone_with_link_delta
drive:num_owned_items_with_visibility_anyone_with_link_removed
drive:num_owned_items_with_visibility_private_added
drive:num_owned_items_with_visibility_private_delta
drive:num_owned_items_with_visibility_private_removed
drive:num_owned_items_with_visibility_public_added
drive:num_owned_items_with_visibility_public_delta
drive:num_owned_items_with_visibility_public_removed
drive:num_owned_items_with_visibility_shared_externally_added
drive:num_owned_items_with_visibility_shared_externally_delta
drive:num_owned_items_with_visibility_shared_externally_removed
drive:num_owned_items_with_visibility_shared_internally_added
drive:num_owned_items_with_visibility_shared_internally_delta
drive:num_owned_items_with_visibility_shared_internally_removed
drive:num_owned_items_with_visibility_unknown_added
drive:num_owned_items_with_visibility_unknown_delta
drive:num_owned_items_with_visibility_unknown_removed
drive:num_owned_other_types_added
drive:num_owned_other_types_created
drive:num_owned_other_types_delta
drive:num_owned_other_types_edited
drive:num_owned_other_types_removed
drive:num_owned_other_types_trashed
drive:num_owned_other_types_viewed
gmail:is_gmail_enabled
gmail:last_access_time
gmail:last_imap_time
gmail:last_interaction_time
gmail:last_pop_time
gmail:last_webmail_time
gmail:num_emails_exchanged
gmail:num_emails_received
gmail:num_emails_sent
gmail:num_spam_emails_received
gplus:num_plusones
gplus:num_plusones_received
gplus:num_replies
gplus:num_replies_received
gplus:num_reshares
gplus:num_reshares_received
gplus:num_shares