Skip to content

Commit

Permalink
Merge pull request #262 from nwls-hermesj/master
Browse files Browse the repository at this point in the history
new InputObject parameter
  • Loading branch information
scrthq authored Feb 28, 2020
2 parents 8208280 + 18712b8 commit 166a23b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
7 changes: 1 addition & 6 deletions PSGSuite/Public/Drive/Get-GSDriveFileList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,7 @@ function Get-GSDriveFileList {
}
}
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'
Expand Down
34 changes: 17 additions & 17 deletions PSGSuite/Public/Drive/Remove-GSDriveFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 {
Expand Down

0 comments on commit 166a23b

Please sign in to comment.