-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get Folder Size ! #204
Labels
Comments
Hey @chrispaivacwb - Thanks for opening this up! Here's the sample wrapper function I shared with you in Slack while I work on fully integrating this in PSGSuite! function Get-GSDriveFolderSize {
[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 -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
}
} |
scrthq
added a commit
that referenced
this issue
Jul 17, 2019
## 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.
scrthq
added a commit
that referenced
this issue
Jul 17, 2019
## 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.
deployed! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
I am in the process of Migration from GSuite to Office365 and I need to know the amount of data I need to manage in this migration. Google Admin Console shows a infomations of usage resources but I am not sure if this info does include Shared Team Drives plus Individual Drive amount.
Describe the solution you'd like
I would like to list all users resources usage from personal Drive and Team Drive distinctly.
Describe alternatives you've considered
Possibility to list all folders sizes recursively showing the amount of each one in a csv file.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: