Shared Drive Properties

132 views
Skip to first unread message

Chad Frerichs

unread,
Mar 5, 2022, 8:33:04 AM3/5/22
to Google Apps Script Community
I'm attempting to output information on all shared drives in a domain with the snippet below. However, the only properties that are populating are id and name. What am I doing wrong?

function listSharedDrives()
{
  Logger.log("Getting Shared Drives");
  var pageToken;
  var page;
  do {
    page = Drive.Drives.list({
      pageToken:pageToken,
      maxResults: 100,
      orderBy: 'name',
      useDomainAdminAccess:true,
      supportsAllDrives:true
    });
    var drives = page.items;
    if (drives) {
      for (var i = 0; i < drives.length; i++) {
        var drive = drives[i];
        var name = drive.name;
        var driveID = drive.id;
        var color = drive.colorRgb;
        var createdDate = drive.createdDate;
        var capabilities = drive.capabilities;
        var hidden = drive.hidden;
        var orgUnitId = drive.orgUnitId;
        var restrictions = drive.restrictions;
        var themeId = drive.themeId;var permissions = Drive.Permissions.list(driveID, {useDomainAdminAccess:true, supportsAllDrives:true}).items;
      }
    }
    pageToken = page.nextPageToken;
  } while (pageToken);
}

Tanaike

unread,
Mar 6, 2022, 7:16:24 AM3/6/22
to Google Apps Script Community
I think that in the case of the method of "Drives: list", there is no property of "supportsAllDrives". Ref And, in your situation, how about using the property of "fields" as follows? When your script is modified, how about the following modification?


From:

page = Drive.Drives.list({
  pageToken:pageToken,
  maxResults: 100,
  orderBy: 'name',
  useDomainAdminAccess:true,
  supportsAllDrives:true
});

To:


page = Drive.Drives.list({
  pageToken:pageToken,
  maxResults: 100,
  orderBy: 'name',
  useDomainAdminAccess:true,
  fields: "*"
});

When I tested this modification, the properties in this official document can be seen.

Chad Frerichs

unread,
Mar 7, 2022, 5:07:27 AM3/7/22
to Google Apps Script Community
@Tanaike , that was the ticket, and I can't believe I missed it!
Addint the fields:"*" did the trick.

Thank you!

Reply all
Reply to author
Forward
0 new messages