I need a quick way to move around and work with users on a large
scale. I have roughly 4500 users already. My first task is to move
users to groups based on Sub-Org. I have started playing with GAM but
not really getting anywhere useful.
I wrote a script that is supposed to move users to groups based on Sub-
Org:
#!/bin/bash
shopt -s expand_aliases
alias gam="python /Applications/gam-2.1.3-python-src/gam.py"
# 2013 is a Google OU
declare -a GAppsUsers=$(gam print users ou | grep 'Students/AHS/2013'
| awk -F, '{print $2}' | sed -e 's/^[ \t]*//')
#echo "$GAppsUsers"
for i in $GAppsUsers; do
# echo "User $i"
# 2013 is a Google group
gam update group 2013 add member $i
done
I have GAM installed properly and the group "2013" is already created.
When I run this script I get the following error:
Karl-Hehr:gam-2.1.3-python-src karlhehr$ /Users/karlhehr/Desktop/
GAFEGroup2013.sh
Getting all users in the organization (may take some time on a large
Google Apps account)...
done.
Traceback (most recent call last):
File "/Applications/gam-2.1.3-python-src/gam.py", line 3008, in
<module>
doUpdateGroup()
File "/Applications/gam-2.1.3-python-src/gam.py", line 1271, in
doUpdateGroup
result = groupObj.AddMemberToGroup(email, group)
File "/Applications/gam-2.1.3-python-src/gdata/apps/groups/
service.py", line 219, in AddMemberToGroup
return self._PostProperties(uri, properties)
File "/Applications/gam-2.1.3-python-src/gdata/apps/service.py",
line 532, in _PostProperties
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
gdata.apps.service.AppsForYourDomainException: {'status': 400, 'body':
'<?xml version="1.0" encoding="UTF-8"?>\r\n<AppsForYourDomainErrors>\r
\n <error errorCode="1303" invalidInput="OU
6602...@ames.k12.ia.us"
reason="EntityNameNotValid" />\r\n</AppsForYourDomainErrors>\r\n\r\n',
'reason': 'Bad Request'}
Now if there is a better way to do this I am all ears, but so far the
ONLY way I have successfully moved users to groups is 25 at a time....
AND THAT SUCKS.
Thanks in advance!
--Karl Hehr