-2

I've been using GAM to locate all google site Drive files in my workspace domain and now have a list of addresses like this:

https://sites.google.com/d/1450940359u5609586456/edit

I'm trying to find a way to locate the published URL of the drive google site file but I'm not sure it's possible. GAM does not provide the info when the drive file is interogated. I'm interested in any solution, not just based on GAM.

Yancy Godoy
  • 582
  • 2
  • 13
  • If I understood correctly you would like to list the URLs of all the files in your Google Drive. Did I understand correctly? – Oriol Castander Mar 08 '22 at 12:06
  • @OriolCastander I am trying to find the addresses of all sites published by members of my workspace domain. At the moment all I can obtain is the source files in the user's Drives. drive locations look like this: https://sites.google.com/d/1450940359u5609586456/edit whereas published urls look like this: https://sites.google.com/myorg.com/sitename/home – user1412705 Mar 08 '22 at 16:19
  • 1
    That is not possible, at least it is not directly possible from Google Drive. – Oriol Castander Mar 15 '22 at 17:02

3 Answers3

1

It's not currently possible to get a site's published URL using GAM. GAM relies on Google's APIs and there is not one available for new Sites:

The Sites APIs currently support only classic Sites. These APIs do not support new Sites. -- https://support.google.com/a/answer/7181011?hl=en

Despite Google's repeated assurances that new Sites would be able to do everything classic Sites did, seven years on this is one of a number of unfilled gaps.

If you are only interested in sites with a "Custom URL," these can easily be viewed in the Google Workspace Admin under Apps → Google Workspace → Sites → Custom URL:

Screenshot showing where to find Custom URL mapping

If you want to know about all sites, there is no good solution I'm aware of. One possible workaround is to give yourself access to every single site using GAM and then inspect each Site manually or using some sort of RPA or browser scripting tool.

Before you start down this path, generate a list of all the Sites in your domain and export it to Google Sheets (the quantity of results might help you decide how far to pursue this idea):

gam all users show filelist todrive query "mimeType = 'application/vnd.google-apps.site'"

Hint: To narrow down the scope of this and all other GAM commands listed here you may want to replace all users with ou "OU/Sub-OU" or you could audit a subset of users by adding them to a new group called sites-audit-users@example.com and use group sites-audit-users throughout.

If you decide to proceed, the high level steps are:

  1. Create an "Auditor" group to use for this process
  2. Give the Auditor group edit access to all the sites in the domain
  3. Inspect all the sites (manually or automatically)
  4. Delete the Auditor group

1. Create Auditor group and add yourself

gam create group name "Sites Auditor - April 2023" email sites.auditor@example.org
gam update group sites.auditor@example.org add owner user my.name@example.org

2. Give the Auditor group access to all sites

gam all users show filelist id title alternateLink query "mimeType = 'application/vnd.google-apps.site'" | tee sites.csv | gam csv - gam user ~Owner add drivefileacl ~id group sites.auditor@example.org role editor

Note: This uses tee to both pipe the output to the next GAM command and save it to a file called sites.csv in your current directory. Windows users may need to install a version of tee themselves for this command to work.

3. Inspect all the sites

The sites will all be listed in sites.csv. You can open the edit interface for each site (manually or programmatically) using the URL in the alternateLink column.

If inspecting manually, open the "Publish settings..." screen under the "Publish" dropdown menu:

Screenshot showing the "Publish settings..." menu option

If inspecting using some sort of browser scripting or RPA tool such as Selenium, UIPath or Power Automate, be aware that some sites may have one or more custom URLs in addition to their "normal" URL:

Screenshot of a site with additional custom URLs

4. Delete the Auditor group

Optional but thorough: Deleting the group will effectively remove the permissions from all the sites but an ACL entry for the deleted group will remain in each file. If you wish to be more thorough you should first remove the Auditor group permission from each file using the CSV we saved earlier:

gam csv sites.csv gam user ~Owner delete drivefileacl ~id group sites.auditor@example.org
gam delete group sites.auditor@example.org
Matthew
  • 1,300
  • 12
  • 30
0

It does not appear to be possible to find the Site's published URL from the source Drive file.

-1

It is not possible to find all google Drive files in your workspace using GAM.

However,it can be easily achieved using google Apps Script and the DriveApp class. By using the getFiles() function (you can read more about it here) you can retrieve a list of all your files in Google Drive. Then you can extract the url of those files quite easily, like in the example below.

function myFunction() {
  var iterator = DriveApp.getFiles();

  while (iterator.hasNext()){
    var file = iterator.next();
    console.log(file.getUrl());
  }
}

Oriol Castander
  • 640
  • 1
  • 5
  • 1
    getUrl() will provide the URL of the drive file, not the publishsed URL of the site. As you commented previously, there doesn't appear to be a way to achieve what I'm trying to do. – user1412705 Apr 04 '22 at 08:49