Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kevinblumenfeld/986cf0d3417d62e2a9aeef8dbd935727 to your computer and use it in GitHub Desktop.
Save kevinblumenfeld/986cf0d3417d62e2a9aeef8dbd935727 to your computer and use it in GitHub Desktop.
function Get-LAFolderSize {
<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
#>
[CmdletBinding()]
Param
(
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true)]
[string[]] $upn
)
Begin {
$resultArray = @()
}
Process {
$stats = Get-MailboxFolderStatistics -Identity $_.userprincipalname | where {$_.name -match "Recoverable Items|Top of Information Store"} | Select @{name = "Size"; expression = {[math]::Round((($_.FolderAndSubfolderSize.ToString()).Split("(")[1].Split(" ")[0].Replace(",", "") / 1GB), 2)}}
Write-Output "UPN: $($_.userprincipalname)"
$Hash = [ordered]@{}
$Hash['UserPrincipalName'] = ($_.userprincipalname)
$Hash['RecoverableItemsSize'] = $stats[0].size
$Hash['TotalSize'] = $stats[1].size
$resultArray += [psCustomObject]$Hash
}
End {
$resultArray
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment