Multiple GAM commands in one invocation?

226 views
Skip to first unread message

Admin@K-12-School

unread,
Nov 12, 2023, 11:43:28 AM11/12/23
to GAM for Google Workspace
I wonder if GAM could be used to issue multiple commands so that oauth process will be performed only once. Would make faster processing?
For instance,

GAM MULTI GAM <command1>, GAM <command2>

Ross, your thoughts?

Ross Scroggs

unread,
Nov 12, 2023, 11:55:31 AM11/12/23
to google-ap...@googlegroups.com
See: https://github.com/taers232c/GAMADV-XTD3/wiki/Bulk-Processing

GAM has batch files but each command is run independently.

What is the nature of the commands you're want to execute.

Ross
----
Ross Scroggs



--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/6f329b94-a4ce-49af-8579-299c5f9b7ff2n%40googlegroups.com.

Admin@K-12-School

unread,
Nov 12, 2023, 5:00:02 PM11/12/23
to GAM for Google Workspace
That would not be a problem, but at least the oauth process wold be performed only once?

Ross Scroggs

unread,
Nov 12, 2023, 6:16:15 PM11/12/23
to google-ap...@googlegroups.com
The oauth process is performed once for each client access command; it is performed
once for every user with service account command.

Again, What is the nature of the commands you want to execute.

Ross
----
Ross Scroggs


Admin@K-12-School

unread,
Nov 13, 2023, 3:17:25 AM11/13/23
to GAM for Google Workspace
Just curiosity about timings...

I am running a powershell script which will query custom fields and update gmail signature accordingly. It takes 25 seconds per user, just wondering if I could speed up operations. This a chunk, the whole script is a bit longer

$executionTime = Measure-Command {
# Place your code block here
Write-Host "Retrieving $user data..."
$u = gam info user $user formatjson | ConvertFrom-Json
Write-Host "Retrieving custom fields.."
$cc = gam info user $user nogroups custom CustomSignature formatjson | ConvertFrom-Json -Depth 10
$myTemplate = $template -replace '##NAME##', $u.name.fullName -replace '##EMAIL##', "$user$domain"
$role = $cc.customSchemas.CustomSignature.Role
if ($cc.customSchemas.CustomSignature.Role){
$myTemplate = $myTemplate -replace '##ROLE##', "$role<br>"
}else{
$myTemplate = $myTemplate -replace '##ROLE##', ""
}
Write-Host "Updating signature"
gam user $user signature $myTemplate
}

# Display the total time taken
$executionTime.TotalMilliseconds / 1000

Ross Scroggs

unread,
Nov 13, 2023, 10:44:13 AM11/13/23
to google-ap...@googlegroups.com
Try this:

$u = gam info user $user quick fields name custom CustomSignature formatjson | ConvertFrom-Json -Depth 10


Drop $cc = and use $u instead of $cc in remaining steps


Ross




--

Greg Joiner

unread,
Nov 13, 2023, 12:11:33 PM11/13/23
to GAM for Google Workspace
You can use input files for most commands, but they still run one by one and if you get a warning or error there is no indication about what the source command line was, so they are useless.
I split my jobs into individual line commands, but run 4 of them at once to cut the time down, then do a re-direct of the console out to a log file for review.
Reply all
Reply to author
Forward
0 new messages