Search code examples
shellgoogle-workspacegam

Can I use GAM with multiple domains?


I need to run some GAM scripts across two domains as a client is migrating; is this possible? I've been trying to find any documentation on setup but there doesn't seem to be :/

Any help is appreciated!

Note: This is not a question about primary or secondary domains - if you need more information on primary/secondary switching I've found GAM3DirectoryCommands to be very helpful and descriptive!


Solution

  • It's not directly possible; however you can achieve this in the following manner:

    • create a CONFIGS folder (you can actually call this wahtever makes sense to you), and a sub-folder for each domain
    • move your client_secrets.json, oauth2.txt and oauth2service.json files from you GAM install folder into your newly-created domain folder
    • run gam info domain and gam info user to see how this affected your gam install
    • to create a new domain setup, run gam create project
    • once complete, run gam info domain and gam info user again to see the difference
    • remember to save your new config to your CONFIGS folder for this new domain too!
    • when you've replaced the config files, run gam user <your_admin_account_for_the_current_domain> check serviceaccount before running any commands, otherwise you're likely to get some errors ;)

    Now you can switch between domains by replacing client_secrets.json, oauth2.txt and oauth2service.json in your GAM install folder (and remember to check serviceaccount).

    Obviously there are many more elegant ways to do this - but this will form the basis of your powershell script in any case ;P

    Hope this helps!