To retrieve the owner of a shared drive using Google Apps Script, you can use the DriveApp service along with the getOwner() method. Here's how you can modify your code to achieve this:
javascriptfunction getSharedDriveOwner() { const folders = DriveApp.getFolders(); while (folders.hasNext()) { const folder = folders.next(); if (folder.isShared()) { const owner = folder.getOwner(); Logger.log('Owner: ' + owner.getEmail()); } } }
In this code:
DriveApp.getFolders().folder.isShared().folder.getOwner().getEmail().Logger.log().Make sure to run this function from the Apps Script editor (usually found in Google Sheets, Docs, or Slides by going to Extensions > Apps Script), and then check the execution log to see the owner's email address printed there.
Please note that this code will only work for folders (shared drives) and not for individual files. If you need to retrieve the owner of a specific file, you can use DriveApp.getFileById(fileId) to get the file object and then use file.getOwner().getEmail() to get the owner's email.
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/4630c02d-0113-45ce-bee8-0462086130cdn%40googlegroups.com.