SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
234 stars 66 forks source link

Managing 'Add to my Drive' Shortcut Functionality. #265

Closed Mschram72 closed 4 years ago

Mschram72 commented 4 years ago

Is your feature request related to a problem? Please describe. My user base needs drive files 'added to their drive' rather than shared, because they can't be bothered to click 'shared with me' and then browse through files.

Describe the solution you'd like A cmdlet or flag on the existing cmdlets that emulates the function of right clicking a shared directory (folder) in Drive, and clicking the 'Add to my Drive' button. This adds a shortcut to the user's Drive but the files permissions, ownership, etc remain unchanged - it is not a copy of the file, but simply a shortcut.

Describe alternatives you've considered Training. But ultimately if I could automate this process it would be ideal. The functionality may already exist in PSGSuite, but I would like some details on how to use it. I can currently access the target directory just fine via Get-GSDriveFile and can make copies, change permissions, etc. But what I need is the ability to perform an 'Add to My Drive' on the directory for a target list of users.

Additional context Add any other context or screenshots about the feature request here.

scrthq commented 4 years ago

Hey @Mschram72 - Thanks for opening this up! I like the idea and am trying to think of how that could happen. I'm anticipating that it can be done by changing the Parents value on the Drive File to include the folder ID for your target Drive location.

Since it seems like you're able to get the file info when it's first shared using Get-GSDriveFileInfo based on the description, my first test once I have time for this would be...

  1. Share a file, but do not Add to My Drive.
  2. $before = Get-GSDriveFileInfo $fileId
  3. In the Drive UI, go through the normal process of right-clicking and selecting Add to My Drive.
  4. $after = Get-GSDriveFileInfo $fileId

Once done, compare $before with $after and scope what's changed.

Mschram72 commented 4 years ago

The above worked perfectly - I was able to grab the root ID of a user's drive, and then add that string the parent field on the desired share via Update-GSDriveFile -AddParents

You're an absolute legend, and thanks as always for the help!

scrthq commented 4 years ago

winning