Find the owner based on file ID?

838 views
Skip to first unread message

Rob Barnes

unread,
Aug 3, 2018, 4:55:34 PM8/3/18
to GAM for G Suite
If I have a Drive file ID, is there any way to use that to find the owner of the file?  It seems like all of the commands require the user to be one of the inputs, but is it possible without knowing who the user is?

Ross Scroggs

unread,
Aug 3, 2018, 5:49:19 PM8/3/18
to google-ap...@googlegroups.com
Rob,

I added a command to do this to my Advanced GAM (https://github.com/taers232c/GAMADV-XTD)

gam show ownership <DriveFileID>|(drivefilename <DriveFileName>) [formatjson]

gam print ownership <DriveFileID>|(drivefilename <DriveFileName>) [todrive [<ToDriveAttributes>]] [formatjson] [quotechar <Character>]


It is a cleaned up version of the following:

gam report drive filter="doc_id==Put File ID here" > id.csv

Open id.csv in a spreadsheet program

Look in the columns parameters.N.name for a row with the value owner; the adjacent column parameters.N.value will have the owner email address.


This only works if the file has been accessed in the last 180 days.


Ross


On Fri, Aug 3, 2018 at 1:55 PM Rob Barnes <robby....@springmobile.com> wrote:
If I have a Drive file ID, is there any way to use that to find the owner of the file?  It seems like all of the commands require the user to be one of the inputs, but is it possible without knowing who the user is?

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/f11da43e-771f-4097-a914-bfcdc2140449%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Rob Barnes

unread,
Aug 3, 2018, 5:54:53 PM8/3/18
to GAM for G Suite
As always, thank you so much!  This worked like a champ!


+KimNilsson

unread,
Oct 22, 2018, 9:21:19 AM10/22/18
to GAM for G Suite
And now I of course have a file not accessed within those 180 days. :-/
Google is reporting  failing app-script on a file, but I don't seem to have access to the file.

Bri Hatch

unread,
Oct 22, 2018, 12:06:44 PM10/22/18
to google-ap...@googlegroups.com
I wonder if you try to open it if that counts as access, even if you don't have permissions to do so?

On Mon, Oct 22, 2018 at 6:21 AM +KimNilsson <there.is.no...@gmail.com> wrote:
And now I of course have a file not accessed within those 180 days. :-/
Google is reporting  failing app-script on a file, but I don't seem to have access to the file.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.


--
Bri Hatch, Systems and Security Engineer. http://www.ifokr.org/bri/

The sooner you fall behind, the more time you'll have to catch up.

Kim Nilsson

unread,
Oct 22, 2018, 12:23:45 PM10/22/18
to google-ap...@googlegroups.com
Sadly, no. 
I tried that. 

/Kim Nilsson
No Substitute
google.com/+KimNilsson

You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/FybCLt3In4c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

Bradley Stinson

unread,
Oct 22, 2018, 12:30:11 PM10/22/18
to google-ap...@googlegroups.com
I haven't tried it but I wonder if you can just add a drivefileacl for yourself to get access and if it will work if you are a super admin.

gam user <user email> add drivefileacl <file id> user <user email>


Kim Nilsson

unread,
Oct 22, 2018, 12:34:32 PM10/22/18
to google-ap...@googlegroups.com
If you check the syntax you can see that there is a reference to the owner in the beginning. 


/Kim Nilsson
No Substitute
google.com/+KimNilsson

Steve - DynTech

unread,
May 3, 2019, 5:11:32 PM5/3/19
to GAM for G Suite
What did I do wrong here? Seems like what Ross said the command should be
gam report drive filter="doc_id==1I6uSORoOJTrJFndCP-FY95YZ6yEIcFBIv--k3vvOgWg"



On Friday, 3 August 2018 16:49:19 UTC-5, Ross Scroggs wrote:
Rob,

I added a command to do this to my Advanced GAM (https://github.com/taers232c/GAMADV-XTD)

gam show ownership <DriveFileID>|(drivefilename <DriveFileName>) [formatjson]

gam print ownership <DriveFileID>|(drivefilename <DriveFileName>) [todrive [<ToDriveAttributes>]] [formatjson] [quotechar <Character>]


It is a cleaned up version of the following:

gam report drive filter="doc_id==Put File ID here" > id.csv

Open id.csv in a spreadsheet program

Look in the columns parameters.N.name for a row with the value owner; the adjacent column parameters.N.value will have the owner email address.


This only works if the file has been accessed in the last 180 days.


Ross


Steve - DynTech

unread,
May 3, 2019, 5:16:31 PM5/3/19
to GAM for G Suite
no = after filter - thanks for the quick call ross :)

gam report drive filter "doc_id==1I6uSORoOJTrJFndCP-FY95YZ6yEIcFBIv--k3vvOgWg"

Markus Frömmel

unread,
Feb 27, 2020, 6:47:59 PM2/27/20
to GAM for G Suite
Hello Ross,

this is fantastic! 3 questions:

  1. What would I need to change to search for multiple ids at once?

  2. if I don't get any results it means I should loop though each and every account to find the owner? which would be the most API efficient call to achieve this? I am thinking about something like this:
    gam all users show fileinfo 1xeutuazvOx...wz9xVpiW21XuRSdSk
    a quick test is showing me it does indeed loop though the users and I can see the info as soon as it hits an editor (or viewer?) I wonder if this is the most efficient way though ...

  3. would it be possible to make the find owner command try to do what I suggested in Question 2 ? 😀 e.g. it could ask "Owner not found, because file was not accessed in the last 180 days. Do you want to run an extensive search? It may take some time on a large G Suite Account..."

Cheers, Markus


Am Freitag, 3. August 2018 23:49:19 UTC+2 schrieb Ross Scroggs:
Rob,

I added a command to do this to my Advanced GAM (https://github.com/taers232c/GAMADV-XTD)

gam show ownership <DriveFileID>|(drivefilename <DriveFileName>) [formatjson]

gam print ownership <DriveFileID>|(drivefilename <DriveFileName>) [todrive [<ToDriveAttributes>]] [formatjson] [quotechar <Character>]


It is a cleaned up version of the following:

gam report drive filter="doc_id==Put File ID here" > id.csv

Open id.csv in a spreadsheet program

Look in the columns parameters.N.name for a row with the value owner; the adjacent column parameters.N.value will have the owner email address.


This only works if the file has been accessed in the last 180 days.


Ross


On Fri, Aug 3, 2018 at 1:55 PM Rob Barnes <robby...@springmobile.com> wrote:
If I have a Drive file ID, is there any way to use that to find the owner of the file?  It seems like all of the commands require the user to be one of the inputs, but is it possible without knowing who the user is?

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

Ross Scroggs

unread,
Feb 27, 2020, 7:16:58 PM2/27/20
to google-ap...@googlegroups.com
Markus,

1: Simple case:
gam redirect user us...@domain.com print filelist select ids 1234,5678 fields id,name,owners.emailaddress norecursion

2: All users case:
How many ids? A few or a lot?
A few:

gam config auto_batch_min 1 redirect csv ./FileOwners.csv multiprocess redirect stderr ./FileCheck.err multiprocess all users print filelist select ids 1234,5678 fields id,name,owners.emailaddress norecursion

Substitute - for ./FileOwners.csv if you just want to watch the screen

A lot:
Put the file ids in a one-column, no header CSV file.
fileids.csv
1234
5678
...
gam config auto_batch_min 1 redirect csv ./FileOwners.csv multiprocess redirect stderr ./FileCheck.err multiprocess all users print filelist select file fileids.csv fields id,name,owners.emailaddress norecursion
Substitute - for ./FileOwners.csv if you just want to watch the screen

3: The suggestion can be added to the Wiki.

Ross

On Thu, Feb 27, 2020 at 3:48 PM Markus Frömmel <mar...@zen-it.berlin> wrote:
Hello Ross,

this is fantastic! 3 questions:

  1. What would I need to change to search for multiple ids at once?

  2. if I don't get any results it means I should loop though each and every account to find the owner? which would be the most API efficient call to achieve this? I am thinking about something like this:
    gam all users show fileinfo 1xeutuazvOx...wz9xVpiW21XuRSdSk
    a quick test is showing me it does indeed loop though the users and I can see the info as soon as it hits an editor (or viewer?) I wonder if this is the most efficient way though ...

  3. would it be possible to make the find owner command try to do what I suggested in Question 2 ? 😀 e.g. it could ask "Owner not found, because file was not accessed in the last 180 days. Do you want to run an extensive search? It may take some time on a large G Suite Account..."

Cheers, Markus

Am Freitag, 3. August 2018 23:49:19 UTC+2 schrieb Ross Scroggs:
Rob,

I added a command to do this to my Advanced GAM (https://github.com/taers232c/GAMADV-XTD)

gam show ownership <DriveFileID>|(drivefilename <DriveFileName>) [formatjson]

gam print ownership <DriveFileID>|(drivefilename <DriveFileName>) [todrive [<ToDriveAttributes>]] [formatjson] [quotechar <Character>]


It is a cleaned up version of the following:

gam report drive filter="doc_id==Put File ID here" > id.csv

Open id.csv in a spreadsheet program

Look in the columns parameters.N.name for a row with the value owner; the adjacent column parameters.N.value will have the owner email address.


This only works if the file has been accessed in the last 180 days.


Ross


On Fri, Aug 3, 2018 at 1:55 PM Rob Barnes <robby...@springmobile.com> wrote:
If I have a Drive file ID, is there any way to use that to find the owner of the file?  It seems like all of the commands require the user to be one of the inputs, but is it possible without knowing who the user is?

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/2389cc96-742d-44d4-b34b-3644eb49b648%40googlegroups.com.


--

Markus Frömmel

unread,
Feb 27, 2020, 7:37:43 PM2/27/20
to GAM for G Suite
Hi Ross,
thanks for the quick answer. However I think we misunderstood each other. I am looking to use the command "gam show ownership", but in a way that it accepts not only a single id, but multiple ids at once. Currently it seems it can only deal with one file at a time, but I guess I can just build a simple pipe/batch to get what I am looking for.

the commands you just posted appear to work only if the user already "sees" the files - It's not the case, however I should be able to figure it out from here by combining this two ideas

Thanks!

Cheers, Markus
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

Ross Scroggs

unread,
Feb 27, 2020, 7:56:52 PM2/27/20
to google-ap...@googlegroups.com
Markus,

To use show ownership with multiple file ids:
Put the file ids in a one-column, CSV file with a header
fileids.csv
fileid
1234
5678

gam redirect stdout ./FileOwners.txt multiprocess redirect stderr ./FileOwners.err multiprocess csv fileids.csv gam show ownership ~fileid

the commands you just posted appear to work only if the user already "sees" the files - It's not the case, however I should be able to figure it out from here by combining this two ideas
That's the point, if the file hasn't been accessed in 180 days, you have to cycle through all users looking for the owner; any user that can see the file can identify the owner.

Ross

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/879314f8-2650-4643-b27a-d2ebf46ab727%40googlegroups.com.


--

Markus Frömmel

unread,
Feb 27, 2020, 8:26:11 PM2/27/20
to GAM for G Suite
Ross, you are truly a genius! Thanks a lot!

that is the result I get

Owner: yo...@domain.de, id: 1O92vMbzX...PgqKuwK2FY, name:, type: msexcel, ownerIsTeamDrive: False, driveId:Owner: ak...@domain.de, id: 1ZXauip...6SRsK4d88lgSc, name:, type: spreadsheet, ownerIsTeamDrive: False, driveId:Owner: hi...@domain.de, id: 1dtZDD...Qx5kBvq-WpKjkJAaZ8, name:, type: spreadsheet, ownerIsTeamDrive: False, driveId:Owner: hi...@domain.de, id: 1JdP1kY...UmQrB55RkdxE_CBcMkc, name:, type: spreadsheet, ownerIsTeamDrive: False, driveId:Owner: to...@domain.de, id: 1xeutuaz...iW21XuRSdSk, name:, type: spreadsheet, ownerIsTeamDrive: False, driveId:

If I may ask one more question: Let's say I want to have more of the csv-like output ... so I use 'print' instead of 'show'
but then it prints the header row every other line. is there a way to avoid that?

example:

Owner,id,name,type,ownerIsTeamDrive,driveId
ak...@domain.de,1ZXauipJ2Z7...RsK4d88lgSc,name1,spreadsheet,False,
Owner,id,name,type,ownerIsTeamDrive,driveId
to...@domain.de,1xeutuaz....piW21XuRSdSk,name2,spreadsheet,False,
Owner,id,name,type,ownerIsTeamDrive,driveId
hir...@domain.de,1JdP1kYJ....rB55RkdxE_CBcMkc,name3,spreadsheet,False,
[...]


Cheers, Markus
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

Ross Scroggs

unread,
Feb 27, 2020, 8:45:43 PM2/27/20
to google-ap...@googlegroups.com
Show me command you entered.

Ross

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/9d8a116c-fbf8-40b5-953e-6182718670c3%40googlegroups.com.


--

Ross Scroggs

unread,
Feb 27, 2020, 8:48:18 PM2/27/20
to google-ap...@googlegroups.com
Markus,

With print you redirect csv, not stdout
gam redirect csv ./FileOwners.csv multiprocess redirect stderr ./FileOwners.err multiprocess csv fileids.csv gam print ownership ~fileid

Ross
--

Markus Frömmel

unread,
Feb 27, 2020, 8:55:20 PM2/27/20
to GAM for G Suite
this is the command i used:

gam redirect stdout ./owners.txt multiprocess redirect stderr ./owners.err multiprocess csv fileids.csv gam print ownership ~id




Am Freitag, 28. Februar 2020 02:48:18 UTC+1 schrieb Ross Scroggs:
Markus,

With print you redirect csv, not stdout
gam redirect csv ./FileOwners.csv multiprocess redirect stderr ./FileOwners.err multiprocess csv fileids.csv gam print ownership ~fileid

Ross
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.


--
Ross Scroggs


--
Ross Scroggs

Ross Scroggs

unread,
Feb 27, 2020, 10:55:07 PM2/27/20
to google-ap...@googlegroups.com
Did this command give you the results you want?
gam redirect csv ./FileOwners.csv multiprocess redirect stderr ./FileOwners.err multiprocess csv fileids.csv gam print ownership ~fileid
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/b28f84e3-8d19-4a47-a6cb-e6c513cef90b%40googlegroups.com.

Markus Frömmel

unread,
Feb 28, 2020, 8:08:48 AM2/28/20
to GAM for G Suite
That is exactly what I needed! Ross, you never fail to impress me – Thanks!


Am Freitag, 28. Februar 2020 04:55:07 UTC+1 schrieb Ross Scroggs:
Did this command give you the results you want?
gam redirect csv ./FileOwners.csv multiprocess redirect stderr ./FileOwners.err multiprocess csv fileids.csv gam print ownership ~fileid
Reply all
Reply to author
Forward
0 new messages