-
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.
Browse files
Browse the repository at this point in the history
## 2.22.1 * [PR #141](#141) - _Thanks, [@dwrusse](https://github.com/dwrusse)!_ * Added: `Remove-GSDriveFile` * Updated: `Get-GSCalendarSubscription` to add support for `List()` requests and added the `ShowHidden` & `ShowDeleted` parameters.
- Loading branch information
Showing
5 changed files
with
108 additions
and
3 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
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,68 @@ | ||
function Remove-GSDriveFile { | ||
<# | ||
.SYNOPSIS | ||
Deletes a Drive file | ||
.DESCRIPTION | ||
Deletes a Drive file | ||
.PARAMETER FileId | ||
The unique Id of the file to get | ||
.PARAMETER User | ||
The email or unique Id of the owner of the Drive file | ||
Defaults to the AdminEmail user | ||
.EXAMPLE | ||
Remove-GSDriveFile -User [email protected] -FileId '1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976' | ||
Deletes the file with ID 1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976 from the user [email protected]'s Drive | ||
#> | ||
[cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] | ||
Param | ||
( | ||
[parameter(Mandatory = $true, Position = 0)] | ||
[String[]] | ||
$FileId, | ||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] | ||
[Alias('Owner', 'PrimaryEmail', 'UserKey', 'Mail')] | ||
[string] | ||
$User = $Script:PSGSuite.AdminEmail | ||
) | ||
Begin { | ||
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 | ||
} | ||
Process { | ||
foreach ($file in $FileId) { | ||
try { | ||
if ($PSCmdlet.ShouldProcess("Deleting File Id '$file' from user '$User'")) { | ||
Write-Verbose "Deleting File Id '$file' from user '$User'" | ||
$request = $service.Files.Delete($file) | ||
$request.SupportsTeamDrives = $true | ||
$request.Execute() | ||
Write-Verbose "File Id '$file' successfully deleted from user '$User'" | ||
} | ||
} | ||
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