-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converted remaining TeamDrive functions to the new Drive namespace an…
…d added Show/Hide-GSDrive functions for #197
- Loading branch information
Showing
7 changed files
with
238 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
function Hide-GSDrive { | ||
<# | ||
.SYNOPSIS | ||
Hides a Shared Drive from the default view | ||
.DESCRIPTION | ||
Hides a Shared Drive from the default view | ||
.PARAMETER DriveId | ||
The unique Id of the Shared Drive to hide | ||
.PARAMETER User | ||
The email or unique Id of the user who you'd like to hide the Shared Drive for. | ||
Defaults to the AdminEmail user. | ||
.EXAMPLE | ||
Hide-GSDrive -DriveId $driveIds | ||
Hides the specified DriveIds for the AdminEmail user | ||
#> | ||
[OutputType('Google.Apis.Drive.v3.Data.Drive')] | ||
[cmdletbinding()] | ||
Param | ||
( | ||
[parameter(Mandatory = $true,ValueFromPipelineByPropertyName = $true,ParameterSetName = "Get")] | ||
[Alias('Id','TeamDriveId')] | ||
[String[]] | ||
$DriveId, | ||
[parameter(Mandatory = $false,Position = 0,ValueFromPipelineByPropertyName = $true)] | ||
[Alias('Owner','PrimaryEmail','UserKey','Mail')] | ||
[string] | ||
$User = $Script:PSGSuite.AdminEmail | ||
) | ||
Process { | ||
if ($User -ceq 'me') { | ||
$User = $Script:PSGSuite.AdminEmail | ||
} | ||
elseif ($User -notlike "*@*.*") { | ||
$User = "$($User)@$($Script:PSGSuite.Domain)" | ||
} | ||
$serviceParams = @{ | ||
Scope = 'https://www.googleapis.com/auth/drive' | ||
ServiceType = 'Google.Apis.Drive.v3.DriveService' | ||
User = $User | ||
} | ||
$service = New-GoogleService @serviceParams | ||
foreach ($id in $DriveId) { | ||
try { | ||
$request = $service.Drives.Hide($id) | ||
Write-Verbose "Hiding Shared Drive '$id' for user '$User'" | ||
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru | ||
} | ||
catch { | ||
if ($ErrorActionPreference -eq 'Stop') { | ||
$PSCmdlet.ThrowTerminatingError($_) | ||
} | ||
else { | ||
Write-Error $_ | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
function Show-GSDrive { | ||
<# | ||
.SYNOPSIS | ||
Shows (unhides) a Shared Drive in the default view | ||
.DESCRIPTION | ||
Shows (unhides) a Shared Drive in the default view | ||
.PARAMETER DriveId | ||
The unique Id of the Shared Drive to unhide | ||
.PARAMETER User | ||
The email or unique Id of the user who you'd like to unhide the Shared Drive for. | ||
Defaults to the AdminEmail user. | ||
.EXAMPLE | ||
Show-GSDrive -DriveId $driveIds | ||
Unhides the specified DriveIds for the AdminEmail user | ||
#> | ||
[OutputType('Google.Apis.Drive.v3.Data.Drive')] | ||
[cmdletbinding()] | ||
Param | ||
( | ||
[parameter(Mandatory = $true,ValueFromPipelineByPropertyName = $true,ParameterSetName = "Get")] | ||
[Alias('Id','TeamDriveId')] | ||
[String[]] | ||
$DriveId, | ||
[parameter(Mandatory = $false,Position = 0,ValueFromPipelineByPropertyName = $true)] | ||
[Alias('Owner','PrimaryEmail','UserKey','Mail')] | ||
[string] | ||
$User = $Script:PSGSuite.AdminEmail | ||
) | ||
Process { | ||
if ($User -ceq 'me') { | ||
$User = $Script:PSGSuite.AdminEmail | ||
} | ||
elseif ($User -notlike "*@*.*") { | ||
$User = "$($User)@$($Script:PSGSuite.Domain)" | ||
} | ||
$serviceParams = @{ | ||
Scope = 'https://www.googleapis.com/auth/drive' | ||
ServiceType = 'Google.Apis.Drive.v3.DriveService' | ||
User = $User | ||
} | ||
$service = New-GoogleService @serviceParams | ||
foreach ($id in $DriveId) { | ||
try { | ||
$request = $service.Drives.Unhide($id) | ||
Write-Verbose "Unhiding Shared Drive '$id' for user '$User'" | ||
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru | ||
} | ||
catch { | ||
if ($ErrorActionPreference -eq 'Stop') { | ||
$PSCmdlet.ThrowTerminatingError($_) | ||
} | ||
else { | ||
Write-Error $_ | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.