Remove shares to external non owner users

This page summarizes the projects mentioned and recommended in the original post on /r/gsuite

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • GAM

    Discontinued command line management for Google Workspace [Moved to: https://github.com/GAM-team/GAM] (by jay0lee)

  • #!/usr/bin/env python2 """ # Purpose: For a Google Drive User(s), show all drive file ACLs for files shared with users outside of your account. # Note: This script can use Basic or Advanced GAM: # https://github.com/jay0lee/GAM # https://github.com/taers232c/GAMADV-XTD3 # Usage: # 1: Get users in account # $ Basic: gam print users > accountusers.csv # $ Advanced: gam redirect csv ./accountusers.csv print users # 2: Get ACLs for all files, if you don't want all users, replace all users with your user selection in the command below # $ Basic: gam all users print filelist id title permissions owners > filelistperms.csv # $ Advanced: gam config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess all users print filelist fields id,title,permissions,owners.emailaddress # 3: From that list of ACLs, output a CSV file with headers "Owner,driveFileId,driveFileTitle,permissionId,role,emailAddress" # that lists the driveFileIds and permissionIds for all ACLs with the non-account users # (n.b., driveFileTitle, role, and emailAddress are not used in the next step, they are included for documentation purposes) # $ python GetSharedWithNonAccountUsersDriveACLs.py accountusers.csv filelistperms.csv deleteperms.csv # 4: Inspect deleteperms.csv, verify that it makes sense and then proceed # 5: Delete the ACLs # $ gam csv deleteperms.csv gam user "~Owner" delete drivefileacl "~driveFileId" "~permissionId" """ import csv import re import sys FILE_NAME = 'name' ALT_FILE_NAME = 'title' QUOTE_CHAR = '"' # Adjust as needed LINE_TERMINATOR = '\n' # On Windows, you probably want '\r\n' PERMISSIONS_N_TYPE = re.compile(r"permissions.(\d+).type") if (len(sys.argv) > 3) and (sys.argv[3] != '-'): outputFile = open(sys.argv[3], 'wb') else: outputFile = sys.stdout outputCSV = csv.DictWriter(outputFile, ['Owner', 'driveFileId', 'driveFileTitle', 'permissionId', 'role', 'emailAddress'], lineterminator=LINE_TERMINATOR, quotechar=QUOTE_CHAR) outputCSV.writeheader() if (len(sys.argv) > 2) and (sys.argv[2] != '-'): inputFile = open(sys.argv[2], 'rbU') else: inputFile = sys.stdin accountUsers = set("[email protected]") usersFile = open(sys.argv[1], 'rbU') for row in csv.DictReader(usersFile, quotechar=QUOTE_CHAR): accountUsers.add(row['primaryEmail']) usersFile.close() for row in csv.DictReader(inputFile, quotechar=QUOTE_CHAR): for k, v in row.iteritems(): mg = PERMISSIONS_N_TYPE.match(k) if mg and v == 'user': permissions_N = mg.group(1) if row.get('permissions.{0}.deleted'.format(permissions_N)) == 'True': continue emailAddress = row['permissions.{0}.emailAddress'.format(permissions_N)] if row['permissions.{0}.role'.format(permissions_N)] != 'owner' and emailAddress not in accountUsers: outputCSV.writerow({'Owner': row['owners.0.emailAddress'], 'driveFileId': row['id'], 'driveFileTitle': row.get(FILE_NAME, row.get(ALT_FILE_NAME, 'Unknown')), 'permissionId': 'id:{0}'.format(row['permissions.{0}.id'.format(permissions_N)]), 'role': row['permissions.{0}.role'.format(permissions_N)], 'emailAddress': emailAddress}) if inputFile != sys.stdin: inputFile.close() if outputFile != sys.stdout: outputFile.close()

  • GAMADV-XTD3

    Command line tool to manage Google Workspace

  • #!/usr/bin/env python2 """ # Purpose: For a Google Drive User(s), show all drive file ACLs for files shared with users outside of your account. # Note: This script can use Basic or Advanced GAM: # https://github.com/jay0lee/GAM # https://github.com/taers232c/GAMADV-XTD3 # Usage: # 1: Get users in account # $ Basic: gam print users > accountusers.csv # $ Advanced: gam redirect csv ./accountusers.csv print users # 2: Get ACLs for all files, if you don't want all users, replace all users with your user selection in the command below # $ Basic: gam all users print filelist id title permissions owners > filelistperms.csv # $ Advanced: gam config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess all users print filelist fields id,title,permissions,owners.emailaddress # 3: From that list of ACLs, output a CSV file with headers "Owner,driveFileId,driveFileTitle,permissionId,role,emailAddress" # that lists the driveFileIds and permissionIds for all ACLs with the non-account users # (n.b., driveFileTitle, role, and emailAddress are not used in the next step, they are included for documentation purposes) # $ python GetSharedWithNonAccountUsersDriveACLs.py accountusers.csv filelistperms.csv deleteperms.csv # 4: Inspect deleteperms.csv, verify that it makes sense and then proceed # 5: Delete the ACLs # $ gam csv deleteperms.csv gam user "~Owner" delete drivefileacl "~driveFileId" "~permissionId" """ import csv import re import sys FILE_NAME = 'name' ALT_FILE_NAME = 'title' QUOTE_CHAR = '"' # Adjust as needed LINE_TERMINATOR = '\n' # On Windows, you probably want '\r\n' PERMISSIONS_N_TYPE = re.compile(r"permissions.(\d+).type") if (len(sys.argv) > 3) and (sys.argv[3] != '-'): outputFile = open(sys.argv[3], 'wb') else: outputFile = sys.stdout outputCSV = csv.DictWriter(outputFile, ['Owner', 'driveFileId', 'driveFileTitle', 'permissionId', 'role', 'emailAddress'], lineterminator=LINE_TERMINATOR, quotechar=QUOTE_CHAR) outputCSV.writeheader() if (len(sys.argv) > 2) and (sys.argv[2] != '-'): inputFile = open(sys.argv[2], 'rbU') else: inputFile = sys.stdin accountUsers = set("[email protected]") usersFile = open(sys.argv[1], 'rbU') for row in csv.DictReader(usersFile, quotechar=QUOTE_CHAR): accountUsers.add(row['primaryEmail']) usersFile.close() for row in csv.DictReader(inputFile, quotechar=QUOTE_CHAR): for k, v in row.iteritems(): mg = PERMISSIONS_N_TYPE.match(k) if mg and v == 'user': permissions_N = mg.group(1) if row.get('permissions.{0}.deleted'.format(permissions_N)) == 'True': continue emailAddress = row['permissions.{0}.emailAddress'.format(permissions_N)] if row['permissions.{0}.role'.format(permissions_N)] != 'owner' and emailAddress not in accountUsers: outputCSV.writerow({'Owner': row['owners.0.emailAddress'], 'driveFileId': row['id'], 'driveFileTitle': row.get(FILE_NAME, row.get(ALT_FILE_NAME, 'Unknown')), 'permissionId': 'id:{0}'.format(row['permissions.{0}.id'.format(permissions_N)]), 'role': row['permissions.{0}.role'.format(permissions_N)], 'emailAddress': emailAddress}) if inputFile != sys.stdin: inputFile.close() if outputFile != sys.stdout: outputFile.close()

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Google Workspace Account deletion and backup

    1 project | /r/sysadmin | 7 Dec 2023
  • Advanced File and Permission Monitoring for Google Drive

    1 project | /r/sysadmin | 30 Jul 2023
  • Deprovisioning script/app?

    1 project | /r/sysadmin | 5 Jul 2023
  • Google Workspace Tools

    1 project | /r/msp | 23 Jun 2023
  • Help with GAM command

    1 project | /r/k12sysadmin | 22 Jun 2023