squid808 / gShell

PowerShell Cmdlets and .Net Libraries for Google Apps and Gmail APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to

ErikN85 opened this issue · comments

I need a little bit help. I want to transfer all data of a user to another user like on the pic but i cant find the right command to do this.

I think it's "new-GDrivePermission". But i don't know how to config is command to make the same like the pic.

transfer

GDrive would be something good for a single item, or selected items, but you would need to set up a service account. I haven't done it myself but if you want what you see in the picture, have you tried the GDataTransfer cmdlets?

Can you give me an example how I should write this.

I try this one too

New-GDataTransferDataObj -NewOwnerUserId max.mustermann -OldOwnerUserId max.mustermann2

but no effects

Sure thing. I hadn't done it yet so it took a bit of testing. I'm including two code bits, one for the current release and one for the upcoming release that fixes a small issue with collection parameters. This is a verbose way of doing it, you can of course shave it down considerably if you want. Though it seems complex, please keep in mind that this is how Google has it set up on their end - you could wrap it in a cmdlet or function if you plan on doing this often.

Current version:

$app = Get-GDataTransferApplication -All | where Name -eq "Drive and Docs"
$old = get-gauser oldUserNameHere
$new = get-gauser newUserNameHere
$ADO = New-GDataTransferApplicationDataObj -ApplicationId $app.Id
$DTO = New-GDataTransferDataObj -OldOwnerUserId $old.userObject.Id `
    -NewOwnerUserId $new.userObject.Id
$DTO.ApplicationDataTransfers = New-Object ("System.Collections.Generic.List[{0}]" -f $ADO.GetType())
$DTO.ApplicationDataTransfers.Add($ADO)
$Transfer = New-GDataTransfer -DataTransferBody $DTO
Get-GDataTransfer -DataTransferId $Transfer.Id

Next version (fixes the need to make a generic list object):

$app = Get-GDataTransferApplication -All | where Name -eq "Drive and Docs"
$old = get-gauser oldUserNameHere
$new = get-gauser newUserNameHere
$DTO = New-GDataTransferDataObj -OldOwnerUserId $old.userObject.Id ` 
    -NewOwnerUserId $new.userObject.Id -ApplicationDataTransfers `
    (New-GDataTransferApplicationDataObj -ApplicationId $app.Id)
$Transfer = New-GDataTransfer -DataTransferBody $DTO
Get-GDataTransfer -DataTransferId $Transfer.Id

The New-GDataTransfer is what initiates the transfer, and you use Get-GDataTransfer to check the status of it (in the OverallTransferStatusCode member of the result - you'll see something like inProgress or Completed).