Feb 01 2022 12:21 PM
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?
Feb 01 2022 11:32 PM - edited Feb 01 2022 11:33 PM
SolutionThat'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.
Feb 07 2022 01:09 AM
Feb 01 2022 11:32 PM - edited Feb 01 2022 11:33 PM
SolutionThat'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.