SOLVED

Exchange Online - Shared Mailbox Size and UPN

Occasional Contributor

Hi Community

 

i try to create a list (and later export it to a CSV with the Size and UPN of all Sahremailboxes below 45GB

Get-EXOMailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Get-EXOMailboxStatistics | Where-Object {[int64]($PSItem.TotalItemSize.Value -replace '.+\(|bytes\)') -lt "45GB"} | Sort-Object TotalItemSize -Descending | Select-Object DisplayName, TotalItemSize, UserPrincipalName 

 

so far so good, but only with DisplayName. the UserPrincipalName i not see, is empty

 

how can I include the UPN in my list? 

2 Replies
best response confirmed by PaddyB (Occasional Contributor)
Solution

That's because you're using a simple one-liner, and working with the output of the last cmdlet in the pipeline, effectively. Get-EXOMailboxStatistics does not have a UserPrincipalName property, thus the value you get is null. If you want to keep the oneliner format, add a calculated field:

 

Get-ExOMailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Select-Object DisplayName, @{n="TotalItemSize";e={(Get-ExOMailboxStatistics $_.UserPrincipalName).TotalItemSize}}, UserPrincipalName | Where-Object {[int64]($_.TotalItemSize.Value -replace '.+\(|bytes\)') -lt "45GB"} | Sort-Object TotalItemSize -Descending


Or use a proper script instead.

you saved my day - thanks for it