Data Transfer (Drive) to another user example

51 views
Skip to first unread message

rishi...@tapad.com

unread,
Mar 31, 2017, 4:34:19 PM3/31/17
to gshell-discuss
Hello,

I'm trying to write a PowerShell script that will transfer ownership of all Google Drive files/docs to a new user but I've not been able to get anything working with the Data Transfer cmdlets.

Has someone got a working example to transfer ownership of google drive data from one user to another?

Thanks,
Rishi

Spencer Varney

unread,
Apr 18, 2017, 9:30:03 AM4/18/17
to rishi...@tapad.com, gshell-discuss
Hi Rishi,

Please take a look at this issue from the past:

In this case, the person was trying to transfer all docs using the data transfer cmdlets. Ultimatly it required a combination of Net-GDataTransfer and Get-GDataTransfer.

Please let me know if this helps.

Regards,

Spencer

--
You received this message because you are subscribed to the Google Groups "gshell-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gshell-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rishi Dhar

unread,
Apr 18, 2017, 10:01:57 AM4/18/17
to Spencer Varney, gshell-discuss
Thanks! I was able to make the drive transfer work.

Thanks,
Rishi

Jon Parodi

unread,
Aug 1, 2017, 7:00:17 PM8/1/17
to gshell-discuss, squi...@gmail.com, rishi...@tapad.com
I know this is a bit late but the information provided in that github how-to didnt fully work for me.  I took a look at https://developers.google.com/admin-sdk/data-transfer/v1/reference/transfers/insert to kind of work through how it is supposed to handle and wrote the following function to transfer all google drive data from one user to another

in the how-to, it did not specify the applicationTransferParams which caused no files to actually transfer (but returned as completed).  Its more lines than necessary but I like readability
$app = Get-GDataTransferApplication -ApplicationId 55656082996

$OldOwner = get-gauser -UserKey $User
$NewOwner = get-gauser -UserKey $targetUser

#Without paramobj, no data was actually transferred
$ApplicationParams = New-GDataTransferApplicationParamObj -Key PRIVACY_LEVEL -Value SHARED,PRIVATE
$ApplicationDataObject = New-GDataTransferApplicationDataObj -ApplicationId $app.Id -ApplicationTransferParams $ApplicationParams
#create new Data Transfer Object

$TDO = New-GDataTransferDataObj `
    -OldOwnerUserId $OldOwner.userObject.ID `
    -NewOwnerUserId $NewOwner.userObject.ID `
    -ApplicationDataTransfers $applicationDataObject

$Transfer = New-GDataTransfer -DataTransferBody $TDO

Get-GDataTransfer -DataTransferId $transfer.Id
Reply all
Reply to author
Forward
0 new messages