-
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.30.0 * [Issue #193](#193) * Added: Drive Revision functions: * `Get-GSDriveRevision` * `Remove-GSDriveRevision` * `Update-GSDriveRevision` * [Issue #210](#210) * Fixed: `Update-GSUser` was not accepting User ID's as the User parameter * [Issue #209](#209) * Added: Support for inline image downloading with `Get-GSGmailMessage` where the image is not included on the Attachments property of the parsed message object. * Fixed: `Get-GSGmailMessage` will now automatically set the `Format` to `Raw` if either `ParseMessage` or `SaveAttachmentsTo` is passed, as `ParseMessage` is a requirement in order to be able to access the message attachments as needed. * [Issue #204](#204) * Added: `Recurse` parameter to `Get-GSDriveFileList` to allow recursively listing all files and subfolders underneath the result set. Confirmed setting the `Limit` parameter also works as expected with `Recurse` included, stopping is the original limit is reached. * Added: `Get-GSDriveFolderSize` function to return the calculated total size of the files in the specified folder(s). * Miscellaneous * Added: `Rfc822MsgId` parameter to `Get-GSGmailMessageList` to easily build a query looking for a specific RFS 822 Message ID. * Added: Pipeline support for `*-GSDrivePermission` functions to enable piping Drive Files into them to manage permissions without looping manually.
- Loading branch information
Showing
15 changed files
with
585 additions
and
45 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
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,63 @@ | ||
function Get-GSDriveFolderSize { | ||
<# | ||
.SYNOPSIS | ||
Gets the size of the files with the specified ParentFolderId in Drive. | ||
.DESCRIPTION | ||
Gets the size of the files with the specified ParentFolderId in Drive. | ||
.PARAMETER ParentFolderId | ||
ID of parent folder to search to add to the filter | ||
.PARAMETER Recurse | ||
If True, recurses through subfolders found underneath primary search results | ||
.PARAMETER Depth | ||
Internal use only. Used to track how deep in the subfolder structure the command is currently searching when used with -Verbose | ||
.EXAMPLE | ||
Get-GSDriveFolderSize -ParentFolderId $id1,$id2 -Recurse | ||
#> | ||
|
||
[CmdletBinding()] | ||
Param ( | ||
[parameter(Mandatory,Position = 0,ValueFromPipelineByPropertyName)] | ||
[Alias('Id')] | ||
[String[]] | ||
$ParentFolderId, | ||
[parameter()] | ||
[Switch] | ||
$Recurse, | ||
[parameter()] | ||
[Int] | ||
$Depth = 0 | ||
) | ||
Begin { | ||
$final = @{ | ||
TotalSize = 0 | ||
} | ||
} | ||
Process { | ||
foreach ($id in $ParentFolderId) { | ||
$files = Get-GSDriveFileList -ParentFolderId $id -IncludeTeamDriveItems -Fields "files(name, id, size, mimeType)" -Verbose:$false | ||
$folderTotal = ($files.Size | Measure-Object -Sum).Sum | ||
if ($folderTotal){ | ||
Write-Verbose ("Total file size in bytes in folder ID '$id': {0}" -f $folderTotal) | ||
$final.TotalSize += $folderTotal | ||
} | ||
if ($Recurse -and ($subfolders = $files | Where-Object {$_.MimeType -eq 'application/vnd.google-apps.folder'})) { | ||
$newDepth = $Depth + 1 | ||
Write-Verbose "[Depth: $Depth > $newDepth] Recursively searching subfolder Ids: [ $($subfolders.Id -join ", ") ]" | ||
$subFolderTotal = Get-GSDriveFolderSize -ParentFolderId $subfolders.Id -Recurse -Depth $newDepth | ||
if ($subFolderTotal) { | ||
$final.TotalSize += $subFolderTotal.TotalSize | ||
} | ||
} | ||
} | ||
} | ||
End { | ||
$final['TotalSizeInMB'] = $final['TotalSize'] / 1MB | ||
$final['TotalSizeInGB'] = $final['TotalSize'] / 1GB | ||
[PSCustomObject]$final | ||
} | ||
} |
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
Oops, something went wrong.