Created
June 11, 2017 23:21
-
-
Save kevinblumenfeld/986cf0d3417d62e2a9aeef8dbd935727 to your computer and use it in GitHub Desktop.
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
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