SOLVED

Exchange Online - Shared Mailbox Size and UPN

%3CLINGO-SUB%20id%3D%22lingo-sub-3101221%22%20slang%3D%22en-US%22%3EExchange%20Online%20-%20Shared%20Mailbox%20Size%20and%20UPN%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3101221%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Community%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20try%20to%20create%20a%20list%20(and%20later%20export%20it%20to%20a%20CSV%20with%20the%20Size%20and%20UPN%20of%20all%20Sahremailboxes%20below%2045GB%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EGet-EXOMailbox%20-RecipientTypeDetails%20SharedMailbox%20-ResultSize%20Unlimited%20%7C%20Get-EXOMailboxStatistics%20%7C%20Where-Object%20%7B%5Bint64%5D(%24PSItem.TotalItemSize.Value%20-replace%20'.%2B%5C(%7Cbytes%5C)')%20-lt%20%2245GB%22%7D%20%7C%20Sort-Object%20TotalItemSize%20-Descending%20%7C%20Select-Object%20DisplayName%2C%20TotalItemSize%2C%20UserPrincipalName%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eso%20far%20so%20good%2C%20but%20only%20with%20DisplayName.%20the%26nbsp%3BUserPrincipalName%20i%20not%20see%2C%20is%20empty%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehow%20can%20I%20include%20the%20UPN%20in%20my%20list%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3101221%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%20Exchange%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
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