Google Apps Manager is a command line tool used to process bulk changes in a Google Apps domain.  The entire feature set of GAM can not be covered in one article, so if you need to find out more, you can visit the GAM Wiki.


When bulk operations are needed, it usually involves scripting of some sort via the command line, with GAM used to process each change separately from a list.  Whether you need to move a list of 200 users into a specific Google Apps ORG, or you need to change licenses for a bunch of users at the same time, or you need to change the same setting on all groups in a specific list, you can use the following command-line.


Windows Command-Line:

Example 1: for /f %A IN (entry-list.txt) DO gam.exe update cros %A ou <OU-Name>


The section in GREEN is the command that will be used for any of these changes.  The red text will change based on what needs to be done.  In this case, we are updating the ORG of Chrome Devices by DeviceID.  In this case, entry-list.txt will consist of one ChromeID per line.


The following is an example of moving users into an ORG.


Example 2: for /f %A IN (entry-list.txt) DO gam.exe update user %A ou <OU-Name>


In this case, entry-list will be the email addresses, one per line of the users to move into the ORG specified by <OU-Name>


Windows PowerShell:

With PowerShell, you can do also loop through a text file of entries.  The difference here, is that there needs to be a header entry which defines the variable name. 


Example 3:

$list = Import-Csv entry-list.txt

foreach ($entry in $list)

{

   .\gam.exe update cros $entry.chromeID ou <OU-Name>

}


In this example, the first entry in the entry-list.txt must be the word chromeID, with the following entries being actual ChromeIDs, but it will process the same command as Example 1 above for each entry in the list.


Example 4:

$list = Import-Csv entry-list.txt

foreach ($entry in $list)

{

   .\gam.exe update user $entry.username ou <OU-Name>

}


In this example, you see a PowerShell version of Example 2 above.  The first entry in the text file must be the word userlist, but it will process the same command as Example 2 above for each entry in the list.


Linux Bash:

With linux you need to create a bash script.  The script also needs to be executable.  For this, I will use the example file looper


looper

---

#!/bin/bash

cat userlist.csv | while read line

do

  ./gam.py update user $line ou <OU-Name>

done

---


The code above will loop through each entry in the userlist.csv file, and process the gam.py command for each user.  Once you create the looper file, you can make it executable.  To do this, use the following command


chmod +x looper


You can then run the command using 


./looper