This lesson is part of the "TAMING GAM - A practical guide to GAM and GAMADV-XTD3" course.

We will be walking through the set-up of GAMADV-XTD3 on an Ubuntu Linux machine. You can follow along with either the video below, or follow the images and steps.

If you are trying to install this on other operating systems, please see these articles:

GAMADV-XTD3 on Windows

GAMADV-XTD3 on macOS

Let's get started.

If you would like to try it yourself, you can start here.

Download And Install GAMADV-XTD3

Let's start by opening a terminal on Ubuntu and running this command.

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

Once that has run, you will see that it has added the GAM Alias to the profile file.

Create GAMConfig and GAMWork Directories

Before you continue, open a separate terminal window to make a couple of directories using the MKDIR command.

GAMConfig and GAMWork

mkdir GAMConfig in the linux terminal

Check that the Alias has been created

Now we need to check that the alias for GAM is in our BASH Terminal using this command.

nano ~/.bashrc

This will open the nano editor. You can use whatever editor you are comfortable with.

Check the bash for the GAM alias

You will see in the last line there, my alias is defined using my path. This will obviously change based on the user that you are logged into your machine as. Once you have confirmed the GAM Alias, you can close the nano editor, using CTRL X.

Create GAMADV-XTD3 Project in Google Workspace

Go back to the first terminal that you started in and answer the question on the screen. "Can you run a full browser on this machine?" And press the Y button and enter.

It says that "GAM is now installed. Are you ready to set up a Google API project for GAM?" Just press Y again and enter.

Enter an Admin Email Address for Google Workspace.

Now type an admin email address that is present in Google Workspace.

Allow the GAM Project Creation in Google Workspace

Click allow on the screen that pops up in your browser to allow the GAM Project Creation to access the Google Account.

Back in the terminal, you will be asked to click on a URL. You can either right-click and copy it or directly click on it, depending on your Terminal Emulator and paste it in a browser.

Create the OAuth client ID

Create and desktop app and name the OAuth client ID for the GAM Project

In the browser that you have opened with the URL, Select "Desktop app" and name the OAuth client ID that you are creating. I have simply called mine GAM Ubuntu or GAM Linux. Then click the create button.

Then copy the Client ID and Client Secret one at a time and paste it into the terminal in the respective places.

Now you need to press Y to "Authorize GAM to perform Google Workspace Management operations as your admin account".

Authorise GAM to perform Google Workspace Management operations

Select GAM Scopes

Now you need to select the scopes that you would like GAM to be responsible for. Each scope is represented by a number. You can either select all the scopes by pressing S, unselect all scopes by pressing U, or just continue by pressing C. If you need to select a scope that has a blank next to it, then type in the number that represents that scope. You can also, if it is supported, make it read-only by adding an R after the number.

Select authorised scopes for GAM

Then authorise the script in the browser window that pops up.

The authorisation of GAM is complete and now we need to authorise GAM to manage Google Workspace data and settings.

GAMADV-XTD3 is now authorised. We need to authorise GAM to manage Google Workspace user data and settings. Just press Y again.

Now you need to type the email address of a regular Google Workspace user.

The authorisation for GAM will fail the first time

This will fail the first time. This is almost a test step. You will be asked to copy a very long URL and paste it into your browser to make this happen.

Select the full URL to authorise GAM

Please select from the top of the red arrow to end of the URL, at the second red arrow. And paste that URL into your browser.

Add a new client ID to Google Workspace

When you paste the URL into your browser you will come to this page. You just need to authorise by pressing the "Authorize" button.

You are now ready to retry the authorisation. Go back to your terminal and press Y. The scopes should all pass now.

You can either close your terminal and open it again, or run this command to get started right away.

alias gam="/home/paul/bin/gamadv-xtd3/gam"

Please make sure that you adapt it for your path.

Testing GAM on Ubuntu Linux

Now run this to test that you are connected to your domain.

gam info domain
GAMADV-XTD3 now runs on Ubuntu

Congratulations, you are ready to run GAMADV-XTD3!

(Optional) Additional things you can run.

There are some other that are suggested that you can run.

Additional Options

gam config customer_id xxxx domain xxxx.com timezone local save verify

What is next?

So that was an quick lesson on how to get GAM set up for your domain on Ubuntu. If you would like more info on how to use GAM and GAMADV-XTD3 for your Google Workspace, please check out this full course of over 9 hours here.

This lesson is part of the "TAMING GAM - A practical guide to GAM and GAMADV-XTD3" course.

Here we will walk you through the set up of GAMADV-XTD3 on a macOS Virtual Machine. This will also work on any version of macOS.

You can either follow along with the images and steps below, or watch the video.

Let's get started.

If you would like to try it yourself, you can start here.

Download And Install GAMADV-XTD3

Let's download the installation of GAMADV-XTD3 from the Downloads page.

At the time of recording this video, we installed GAMADV-XTD3 6.06.09.

Start a terminal session and execute this command, for a new installation in the default path $HOME/bin

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

Depending on how you have set up your macOS, you may be prompted to install the Command Line Tools.

Installing the Command Line tools for macOS

Once that has installed, which may take a couple of minutes, you will see this in your terminal.

bash <(curl -s -S -L https://git.io/fhZWP) Installation of GAMADV-XTD3 on macOS

Open a NEW terminal window.

We need to add a new line of code into the shell.

To get into your shell you will need to know what shell you are using. On a newish Mac, you are probably using ~/.zshrc. To see that this line was entered, we need to open a text editor. You can use whichever is on your machine, we are going to use Nano by running this command.

nano ~/.zshrc
Checking zshrc for the config line created by GAMADV-XTD3

As you can see, there is a line that was added by the installation. We need to add this line into the text editor. And then save the file. To save, use CTRL X and then press Y and then press enter.

export GAMCFGDIR="/Users/admin/GAMConfig"
Adding export GAMCFGDIR="/Users/admin/GAMConfig" to the zshrc shell

Now, let's create a GAMWork and GAMConfig directory in the macOS finder.

Create a GAMWork and GAMConfig directory in the macOS finder

We need to now move into the GAM folder. You will see that I started by running "ls". This will list the folders and files so that I can see where I am. Then I changed directory (cd see the red arrow) and moved myself into the bin/gamadv-xtd3 directory. I then ran "ls" again to see what was in that folder.

Moving into the GAMADV-XTD3 folder

Initialise GAMADV-XTD3

We then want to initialise GAMADV-XTD3 by running this command.

./gam config drive_dir /Users/admin/GAMWork verify

Verify the installation

ls -l ~/.gam

Now return to the first terminal window.

We can run a browser on this machine, so press Y

And then enter a Google Workspace email.

Setting up GAMADV-XTD3

Once you have added the admin email address, it will start running through the process of actually creating the Google App.

Create a GAM desktop App

Select the link provided and paste it into your browser. You will need to make a desktop app and name it something like GAM.

Then copy and paste your Client ID and Client Secret into the terminal.

Then copy and paste your Client ID and Client Secret into the terminal.

Now are you ready to authorise GAM to perform Google Workspace Management Operations? Just type Y

GAM API Scopes

Now choose the API you would like to authorise. You can select all scopes by using S, Unselect all using U, or press C to continue to Authorisation. If you would like to enable or disable API Scopes, you can just type the numbers that correspond to the various Scopes, and they will enable or disable.

If you would like to enable or disable API Scopes, you can just type the numbers that correspond to the various Scopes, and they will enable or disable.

When you press C you will be transferred to your Workspace and you will have to click allow authorising.

When you press C you will be transferred to your Workspace and you will have to click allow authorising.

Then back at the terminal, press Y to advise you are ready to authorise and then type in a regular Workspace user.

These will all fail the first time it runs.

API Scopes are all failing

Then copy and paste the long link from your terminal into your browser.

Copy the URL to authorise Google Workspace

Then we need to authorise the new Client ID.

Then we need to authorise the new Client ID.

Then go back to the terminal and try again by pressing Y and you will see the scopes all passing.

Then go back to the terminal and try again by pressing Y and you will see the scopes all passing.

Either copy and paste the command from your terminal to restart the terminal or just close and open it again. Then we are going to test that it works by running this command.

gam info domain

(Optional) Additional things you can run.

There are some other options that are suggested that you can run.

Additional Options

gam config customer_id xxxx domain xxxx.com timezone local save verify

What is next?

So that was a quick lesson on how to get GAM set up for your domain on macOS. If you would like more info on how to use GAM and GAMADV-XTD3 for your Google Workspace, check out this full online course of over 9 hours, including 50 pages of free resources, here.

This lesson is part of the "TAMING GAM - A practical guide to GAM and GAMADV-XTD3" course.

This lesson walks you through the set up of GAMADV-XTD3 on a Windows 10 Virtual Machine. You can also load it directly on your Windows 10 machine by following along with either the video below, or by following the images and steps detailed below.

Let's get started.

If you would like to try it yourself, you can start here.

Download And Install GAMADV-XTD3

Let's download the installation of GAMADV-XTD3 from the GitHub Releases page.

At the time of recording this video, we installed GAMADV-XTD3 6.06.09.

Then run through the installation of your GAMADV-XTD3. Open the file you downloaded and click next all the way through. Make sure that you make a note of the path that you are installing in.

Installation of GAMADV-XTD3

Then make sure that it has installed into the correct path in your C Drive.

GAM Installation directory

Set a configuration directory

When you install GAM, the default GAM configuration directory is C:\Users.gam.

To make it easier to work with multiple companies, you may want to change it to a non user-specific location. This example assumes that the GAM configuration directory will be C:\GAMConfig; If you've chosen another directory, substitute that value in the directions.

Make the C:\GAMConfig directory before completing the rest of the steps.

Set a working directory

Another tip, to make your processing of commands easier, is to create a GAM working directory.

In this folder you will execute commands from this folder. You should not use C:\GAMADV-XTD3 or C:\GAMConfig for this purpose.

Make the C:\GAMWork directory before completing the rest of the steps.

Create GAMConfig and GAMWork

Set system path and GAM configuration directory

Start Control Panel

Open Control Panel

Click System

Open System in Control Panel

Click Advanced system settings

Click Advanced System Settings

Click Environment Variables

Click Environment Variables…


Click Path under System variables and Click Edit.

Click Path under System variables


If C:\GAMADV-XTD3 is already on the Path, skip the next three steps
Click New
Enter C:\GAMADV-XTD3

Click New
Enter C:\GAMADV-XTD3


Click OK
Click New
Set Variable name: GAMCFGDIR
Set Variable value: C:\GAMConfig
Click OK

Set Variable value: C:\GAMConfig
Click OK


Click OK
Click OK
Exit Control Panel

Initialise GAMADV-XTD3

Open the command prompt and run this command to get into the GAMADV-XTD3 directory.

cd C:\GAMADV-XTD3

Then run this command to initialize GAM

gam config drive_dir C:\GAMWork verify
gam config drive_dir C:\GAMWork verify

Verify initialisation

Once the previous command has run, run this command to verify that the GAM installation has initialised.

dir %GAMCFGDIR%
dir %GAMCFGDIR%

Start Creating your GAM Project

If you still have the command prompt open, then run the below command to create the GAM Project.

gam create project

Then add your Google Admin or GCP Project Manager account to the GAM command

Then, once it runs, copy the link from the command prompt and paste it into your browser.

Then, once it runs, copy the link from the command prompt and paste it into your browser.

Choose Desktop APP

Choose Desktop APP

Name your OAuth Client ID

Name your OAuth Client ID

Now that your OAuth Client has been created, copy your Client ID and Client Secret into the command prompt.

image 18

Now we need to create the OAuth connection.

gam oauth create
The APIs with the stars next to them are going to be enabled.

The APIs with the stars next to them are going to be enabled. Make a selection of what APIs you want and then click "c" to continue. And enter your admin email.

Press allow to enable the APIs

Press allow to enable the APIs

Enable GAMADV-XTD3 service account access.

We now need to test that it has worked for a specific user.

gam user [email protected] check serviceaccount
gam user user@domain.com check serviceaccount

Copy the long URL for the authorisation and paste it into your browser.

 Copy the long URL for the authorisation and paste it into your browser.

Then click authorise.

Then click authorise.

Now to test

Run the same command as before to test that it is authorised.

gam user [email protected] check serviceaccount
Run the same command as before to test that it is authorised.

Now run this to test that you are connected to your domain.

gam info domain
Now run this to test that you are connected to your domain.

Congratulations, you are ready to run GAMADV-XTD3!

(Optional) Additional things you can run.

There are some other that are suggested that you can run.

Additional Options

gam config customer_id xxxx domain xxxx.com timezone local save verify

What is next?

So that was an quick lesson on how to get GAM set up for your domain on Windows 10. If you would like more info on how to use GAM and GAMADV-XTD3 for your Google Workspace, please check out this full course of over 9 hours here.

taers232c/GAMADV-XTD3: Command line tool to manage ... - GitHub
GAMADV-XTD3 is a free, open source command line tool for Google Workspace (formerly G Suite) Administrators to manage domain and user settings quickly and ...

Are you looking to do an advanced date matching and validation with Regular Expressions? Are you trying to make sure that your validation takes into account months with 30 and 31 days, and that pesky February who has 28 days and then every 4 years it has 29 days?!

Then this video below is for you!

Resources for Advanced Date Matching with Regex

https://regex101.com/r/9JIyQs/2 - Simple Example
https://www.debuggex.com/ - Regex Visualizer
https://jex.im/regulex/#!flags=&re=%5E(a%7Cb)*%3F%24 - Another Regex Visualizer
https://taming.tech/Google-Doc-Regex-Planning Thinking behind the Regex for a Date
https://regex101.com/r/YSSP9v/1 - Full Regex for date
https://regex101.com/r/YSSP9v/2 - Blank for you to start with
https://regex101.com/r/YSSP9v/3 - My completed example after demo

About this Regex Tutorial

We break down the complexity, of using 2 different examples of how to validate months using Regex, into bite size chunks. We go through the whole process from scratch and show you the thinking in how to formulate your expressions.

One of the difficulties with working on a new expression is being able to see where you have gone wrong, and then troubleshooting the expressions. Here we use a Regex Visualiser to show you how it works. How the validation goes from 1 side of the Regular Expression and gets thrown out of each leg and is only valid in one place.

In this tutorial we start with a simple example of how to validate against date entries. The problem with this Regex is that if you are looking to reject inputs that might be incorrect like 30/Feb/2001 then this will not stop those from being entered.

Simple Date Matching

(?<MM>[01]?[0-9])\/(?<DD>[0-3]?[0-9])\/(?<YYYY>[0-2][0-9][0-9][0-9])

If you look at the examples from this website https://www.regular-expressions.info/dates.html you will see that they start with this example.

^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$

You can see their code working here https://regex101.com/r/9ec0Ko/1 This still doesn't validate for months working on different days per month or leap years. They do however continue on to validate the dates using Perl code. This is in the yyyy-mm-dd format from 1900-01-01 through 2099-12-31.

sub isvaliddate {
  my $input = shift;
  if ($input =~ m!^((?:19|20)\d\d)[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$!) {
    # At this point, $1 holds the year, $2 the month and $3 the day of the date entered
    if ($3 == 31 and ($2 == 4 or $2 == 6 or $2 == 9 or $2 == 11)) {
      return 0; # 31st of a month with 30 days
    } elsif ($3 >= 30 and $2 == 2) {
      return 0; # February 30th or 31st
    } elsif ($2 == 2 and $3 == 29 and not ($1 % 4 == 0 and ($1 % 100 != 0 or $1 % 400 == 0))) {
      return 0; # February 29th outside a leap year
    } else {
      return 1; # Valid date
    }
  } else {
    return 0; # Not a date
  }
}

That is fine for their example, but I want to have my validation all in one line that can be adapted for Python, PHP, PowerShell etc. so this doesn't work for me.

So we start with a very complex looking expression. If you are happy to just copy and paste then you can use this. But if you want to learn how to do this, then please watch the video.

So we start with a very complex looking expression. If you are happy to just copy and paste then you can use this. But if you want to learn how to do this, then please watch the video.

^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]|(?:Jan|Mar|May|Jul|Aug|Oct|Dec)))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2]|(?:Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)(?:0?2|(?:Feb))\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9]|(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep))|(?:1[0-2]|(?:Oct|Nov|Dec)))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$

Check it out here https://regex101.com/r/YSSP9v/1 We have used the UK and South African date format here of DD/MM/YYYY. You can obviously update this to the international date format of YYYY/MM/DD.

After going through the validation and showing you how to work and troubleshoot your validation, I finished on this expression, which I actually like more than my original example.

^(?<Monthswith31>31(?<s1>\/|\.|-)(0?[13578]|1[02]|(Jan|Mar|May|Jul|Aug|Oct|Dec))\g<s1>(?<Year>19[0-9][0-9]|200[0-7]))$|^(?<Monthswith29or30>(29|30)(?<s2>\/|\.|-)(0?[1,3-9]|1[0-2]|(Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\g<s2>(?<Year2>19[0-9][0-9]|200[0-7]))$|^(?<Allmonthswith28>(0?[1-9]|1[0-9]|2[0-8])(?<s3>\/|\.|-)(0?[1-9]|1[0-2]|(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))\g<s3>(?<Year3>19[0-9][0-9]|200[0-7]))$|^(?<FebLeapYears>29(?<s4>\/|\.|-)(0?2|Feb)\g<s4>(19([02468][048]|[13579][26])|200[04]))$

You can play and test it for yourself here https://regex101.com/r/YSSP9v/3

We have worked with 4 "legs" in this Regex. One to validate all months with 31 days, so that would be Jan, Mar, May, Jul, Aug, Oct, Dec. Then we look at all months with 29 or 30 days, so that would be Jan, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec. Then all the months with 1-28 days so that is all months. Finally, we look at leap years that would have Feb 29 in years like 1996, 2000, 2004 etc. and we play with an easy way to figure out what the year would validate against.

This video is an hour long because I take you through my logic and thinking so that you can figure out any Regex that you would like to play with.

Udemy Regex Course

Taming REGEX

This tutorial is a part of a Regex course on Udemy. Join us using the Udemy Coupon code on that page to get the course for the best possible price.

Taming Tech
Copyright © 2021 Outsource House [OSH.co.za] | All Rights Reserved Website development powered by Doiing.Digital | Training produced by Taming.Tech