0
votes

I need to get all Exchange user mailboxes (cloud) whose TotalDeletedItemSize is greater than 10 GB. This script works great:

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | select DisplayName,TotalDeletedItemSize | Where {(($_.TotalDeletedItemSize -split " ")[0]) -gt 10}

But I also need the output to contain the ALIAS. If I pass the ALIAS using a select after the get-mailbox then the Get-MailboxStatistics throws an error.

1
either break your pipeline into independent steps - so that you can save the output of the 1st step - OR look into something like the -PipelineVariable. for more info, look at Get-Help about_CommonParameters.Lee_Dailey

1 Answers

1
votes

One way to do this is with a foreach loop:

Foreach ($mb in (Get-Mailbox -ResultSize Unlimited)) {

   Get-MailboxStatistics $mb.GUID | select DisplayName,TotalDeletedItemSize,@{n="Alias";e={$mb.alias}} | Where {(($_.TotalDeletedItemSize -split " ")[0]) -gt 10}
}