-
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.
Merge pull request #262 from nwls-hermesj/master
new InputObject parameter
- Loading branch information
Showing
2 changed files
with
18 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,36 +7,36 @@ function Remove-GSDriveFile { | |
Deletes a Drive file | ||
.PARAMETER FileId | ||
The unique Id of the file to get | ||
The unique Id(s) of the file(s) to delete | ||
.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' | ||
Remove-GSDriveFile -FileId '1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976' -User [email protected] | ||
Deletes the file with ID 1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976 from the user [email protected]'s Drive | ||
.EXAMPLE | ||
Get-GSDriveFileList -ParentFolderId '1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976' -User [email protected] | Remove-GSDriveFile | ||
Get the file with ID 1rhsAYTOB_vrpvfwImPmWy0TcVa2sgmQa_9u976 from the user [email protected]'s Drive and pipeline | ||
#> | ||
[cmdletbinding(SupportsShouldProcess = $true, ConfirmImpact = "High")] | ||
Param | ||
( | ||
[parameter(Mandatory = $true, Position = 0)] | ||
Param( | ||
[parameter(Mandatory,ValueFromPipelineByPropertyName,Position = 0)] | ||
[Alias('Id')] | ||
[String[]] | ||
$FileId, | ||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] | ||
[parameter(ValueFromPipelineByPropertyName,Position = 1)] | ||
[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)" | ||
} | ||
Resolve-Email ([ref]$User) | ||
$serviceParams = @{ | ||
Scope = 'https://www.googleapis.com/auth/drive' | ||
ServiceType = 'Google.Apis.Drive.v3.DriveService' | ||
|
@@ -45,12 +45,12 @@ function Remove-GSDriveFile { | |
$service = New-GoogleService @serviceParams | ||
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) | ||
if ($PSCmdlet.ShouldProcess("Deleting File Id '$FileId' from user '$User'")) { | ||
Write-Verbose "Deleting File Id '$FileId' from user '$User'" | ||
$request = $service.Files.Delete($FileId) | ||
$request.SupportsAllDrives = $true | ||
$request.Execute() | ||
Write-Verbose "File Id '$file' successfully deleted from user '$User'" | ||
$request.Execute() | Out-Null | ||
Write-Verbose "File Id '$FileId' successfully deleted from user '$User'" | ||
} | ||
} | ||
catch { | ||
|