I borrowed code from here to download directory data from my Google domain into a spreadsheet. All I changed in the code was to replace OpenByURL with OpenByID because of an invalid argument error. Now it works, except it only returns the first 100 users from my domain. I have about 1000 users total, perhaps a few more. Can I pull all of them? If not, can I at least increase the limit beyond 100? And/or how can I limit my query to a particular Organizational Unit?
My full code below:
function writeToSpreadsheet(){
var values = [];
var users = AdminDirectory.Users.list({domain:'klht.org'}).users; //example: ignitesynergy.com
for (var i=0; i<users.length; i++){
values.push([users[i].name.fullName, users[i].primaryEmail]); //Look in the docs or use auto complete to see what you can access
}
var spreadsheetID = '1JLDD2wm0_udmTn9ZHvdKhL_Ok3SvKYFqkBeiA1GdnYc';
SpreadsheetApp.openById(spreadsheetID).getSheets()[0].getRange(1, 1, values.length, values[0].length).setValues(values);
}
//Red indicates the places you need to use your info