GAM Custom Schema Filtering

395 views
Skip to first unread message

Rhin Bourgeois

unread,
Feb 22, 2024, 1:55:56 PM2/22/24
to GAM for Google Workspace
Hey All,

I've got an interesting use case that I'm trying to filter for with a GAM command. What I'd like to do is query the system for users with a specific domain (example.com) and look for data that sits inside of a custom schema field.

For example, if I execute the following command:

gam print users schemas ExampleSchema > export.csv

This will provide me with a csv file with several unique fields that don't work off a command of Allfields, because (As best I can tell) the customSchema has it's own set of fields that it houses. I'd like to be able to just run something to the effect of:



gam user example.com print users fields email,customSchemas.ExampleSchema

I think this is just a syntax issue with the custom schema that I'm leveraging, but any guidance would be greatly appreciated. Thanks in advanced!

-Rhin

Ross Scroggs

unread,
Feb 22, 2024, 3:27:49 PM2/22/24
to google-ap...@googlegroups.com
Try:
gam user example.com print users fields primaryemail customSchemas ExampleSchema
gam info user example.com fields primaryemail customSchemas ExampleSchema

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/5f5e4cca-8131-4a22-8a20-961d9e02256en%40googlegroups.com.

Rhin Bourgeois

unread,
Feb 22, 2024, 7:49:22 PM2/22/24
to GAM for Google Workspace
Ross,

Thanks for responding. Neither of those commands worked, but I was able to get the results I wanted with the following command:

gam print users domain $domainName fields email custom all | gam csv - gam update user ~primaryEmail email ~"customSchemas.Some.Field"

This will locate all the users with for a specific domain ($domainName - sorry I turned this into a PS script), capture the email field and all the schema fields, then turns around and updates the primaryEmail field for all the user accounts found with a custom schema field. I could not for the life of me figure out how to print out the specified customSchema field. If you are interested in going down a rabbit hole with me, I'd be more than happy to send an invite tomorrow at a convenient time for you. If not, greatly appreciate your support.

-Rhin

Brian Kim

unread,
Feb 23, 2024, 8:34:42 AM2/23/24
to GAM for Google Workspace
You shouldn't need to list all the schemas.

do gam show schemas  and find your schema.

  Schema: AzureAD (4/4)

If I then do 
gam print users fields primaryemail schemas AzureAD

I get a CSV that has below
primaryEmail,customSchemas.AzureAD.ImmutableID

Roberto Iacone

unread,
Dec 24, 2025, 5:10:37 AM (2 days ago) Dec 24
to GAM for Google Workspace
Is there any option to export filtering on a specific value of the custom schema?

For example print users custom CustomSchemaField (where value is XYZ)

Thank you

Roberto Iacone

unread,
Dec 24, 2025, 6:53:03 AM (2 days ago) Dec 24
to GAM for Google Workspace
I think I found the answer myself . Actually two options.

gam config csv_output_row_filter "'customSchemas.MySchema.MyMultiValueField.1.value:text=STRINGTOFILTER'" print users custom MySchema.MyMultiValueField
This has the inconvenience that if the field is like mine and multivalued you will have to search on all indexes of the field 0,1,2 etc

This can be remediated with

gam print users custom MySchema.MyMultiValueField | grep "STRINGTOSEARCHFOR"




I hope others find it useful


Ross Scroggs

unread,
Dec 24, 2025, 11:20:09 AM (2 days ago) Dec 24
to google-ap...@googlegroups.com
Try: gam config csv_output_row_filter "'customSchemas.MySchema.MyMultiValueField.*.value:text=STRINGTOFILTER'" print users custom MySchema.MyMultiValueField

Ross
----
Ross Scroggs


Reply all
Reply to author
Forward
0 new messages