Google Workspace

Google Workspace: Export list of all Chromebooks using Google App Script

Google Workspace doesn’t have an option to export list of Chrome devices. This can be quite frustrating if you have lot of Chromebooks. Using Google Apps Script we can export all Chrome devices for a particular domain to a Google Sheet.

Created a Google Sheet and add below code to Google App Script. Ensure you add Admin API library and account has admin access.

function chromelist() {
//Load active sheet
var thespreadsheet = SpreadsheetApp.openById('XXXXXXXXXXXXXXXXXXXX');
var sheet= thespreadsheet.getSheetByName('Sheet1');
// Determine length
var pageToken,
var e=2;
page = AdminDirectory.Chromeosdevices.list("my_customer",
{maxResults: 500,
pageToken: pageToken,
"query": "status: ACTIVE"
var devices = page.chromeosdevices;
for (device in devices) {
var lastKnownNetwork = devices[device].lastKnownNetwork;
var recentemail = " ";
var wanIP = " ";
if(lastKnownNetwork !== undefined) {
var wanIP = devices[device].lastKnownNetwork[0].wanIpAddress;
var recentUsers = devices[device].recentUsers;
if(recentUsers !== undefined) {
var recentemail = recentUsers[0].email;
var date = ((devices[device].autoUpdateExpiration/1000)-14400)/86400 + 25569;
pageToken = page.nextPageToken;
} while (pageToken);

Leave a Reply

Your email address will not be published. Required fields are marked *