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:
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.
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:
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:
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
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.
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:
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:
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