I found the following article :
https://developers.google.com/admin-sdk/directory/v1/quickstart/apps-script
which instructs you to get all users from your google domain. I'd like to get ALL of the users however, but maxResults seems to limit the results to a maximum of 500 result entries. How can I bypass this and get all users? I'm using the following code.
function listUsers() {
var optionalArgs = {
customer: 'my_customer',
maxResults: 5000,
orderBy: 'email'
};
var response = AdminDirectory.Users.list(optionalArgs);
var users = response.users;
if (users && users.length > 0) {
Logger.log(users.length);
Logger.log('Users:');
for (i = 0; i < users.length; i++) {
var user = users[i];
Logger.log('%s (%s)', user.primaryEmail, user.name.fullName);
}
} else {
Logger.log('No users found.');
}
}