Files
GoogleDriveManagement/docs/Find-File-Owner.md
Ross Scroggs 37f6a9694a
Some checks are pending
Build and test GAM / build (Win64, build, 8, VC-WIN64A, windows-2022) (push) Waiting to run
Build and test GAM / build (aarch64, build, 2, linux-aarch64, [self-hosted linux arm64]) (push) Waiting to run
Build and test GAM / build (aarch64, build, 4, linux-aarch64, [self-hosted linux arm64], yes) (push) Waiting to run
Build and test GAM / build (aarch64, build, 6, darwin64-arm64, macos-14) (push) Waiting to run
Build and test GAM / build (universal2, build, 7, darwin64-arm64 darwin64-x86_64, macos-14) (push) Waiting to run
Build and test GAM / build (x86_64, build, 1, linux-x86_64, ubuntu-20.04) (push) Waiting to run
Build and test GAM / build (x86_64, build, 3, linux-x86_64, ubuntu-20.04, yes) (push) Waiting to run
Build and test GAM / build (x86_64, build, 5, darwin64-x86_64, macos-12) (push) Waiting to run
Build and test GAM / build (x86_64, test, 10, ubuntu-22.04, 3.9) (push) Waiting to run
Build and test GAM / build (x86_64, test, 11, ubuntu-22.04, 3.10) (push) Waiting to run
Build and test GAM / build (x86_64, test, 12, ubuntu-22.04, 3.11) (push) Waiting to run
Build and test GAM / build (x86_64, test, 9, ubuntu-22.04, 3.8) (push) Waiting to run
Build and test GAM / merge (push) Blocked by required conditions
Build and test GAM / publish (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Check for Google Root CA Updates / check-apis (push) Waiting to run
Added options allschemas|(schemas|custom|customschemas <SchemaNameList>) to gam print group-members
2024-08-19 14:12:46 -07:00

3.0 KiB

Find File Owner

API documentation

Definitions

<DriveFileID> ::= <String>
<DriveFileName> ::= <String>

Display File Ownership

These commands use the Reports API audit activity and may not find the owner if the file has not been accessed in 180 days. If you specify a <DriveFileID>, there will be at most one line of output. If you specify a <DriveFileName>, there will be one line of output for each distinct file with that name.

The Reports API calls are:

  • ownership <DriveFileID> - gam report drive filter "doc_id==<DriveFileID>"
  • ownership drivefilename <DriveFileName> - gam report drive filter "doc_title==<DriveFileName>"
gam show ownership <DriveFileID>|(drivefilename <DriveFileName>)
        [formatjson]

By default, Gam displays the information as a list of keys and values.

  • formatjson - Display the output in JSON notation
gam print ownership <DriveFileID>|(drivefilename <DriveFileName>) [todrive <ToDriveAttribute>*]
        (addcsvdata <FieldName> <String>)*
        [formatjson [quotechar <Character>]]
  • addcsvdata <FieldName> <String> - Add additional columns of data from the command line to the output

By default, Gam displays the information as columns of fields; the following option causes the output to be in JSON format.

  • formatjson - Display the fields in JSON format.

By default, when writing CSV files, Gam uses a quote character of double quote ". The quote character is used to enclose columns that contain the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled. When using the formatjson option, double quotes are used extensively in the data resulting in hard to read/process output. The quotechar <Character> option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output. quotechar defaults to gam.cfg/csv_output_quote_char. When uploading CSV files to Google, double quote " should be used.

Display File Ownership for Old files

If the above commands fail, you can try to loop through all accounts, however this might take a long time if you are on a large Google Workspace Account. If any lines are displayed, the file owner is in the owners.0.emailAddress column.

gam config auto_batch_min 1 multiprocessexit rc=0 redirect csv - multiprocess redirect stderr null multiprocess all users print filelist select id <DriveFileID> fields id,name,owners.emailaddress norecursion showownedby any
gam config auto_batch_min 1 multiprocessexit rc=0 redirect csv - multiprocess redirect stderr null multiprocess all users print filelist select name <DriveFileName> fields id,name,owners.emailaddress norecursion showownedby any