question

bernardmwanza-0900 avatar image
0 Votes"
bernardmwanza-0900 asked bernardmwanza-0900 commented

Is it possible to query mailbox statistics for mailbox that has been put on litigation hold then the associated user account deleted in office 365 using powershell

I'm trying to retrieve mailbox statistics for a mailbox that I put on litigation hold, then deleted its associated account in office 365. I know the mailbox is inactive state.

Is it possible to query mailbox statistics for mailbox that has been put on litigation hold then the associated user account deleted in office 365, I need to achieve this using powershell.

My PowerShell script and the error that is getting.

 PS C:\Windows\system32> $inactive = Get-Mailbox -InactiveMailboxOnly
 PS C:\Windows\system32> $user = $inactive.SamAccountName
 PS C:\Windows\system32> $mailstat = Get-MailboxStatistics $user
 The specified mailbox Identity:"$VLHCB0-O2T8NUTCI12G" doesn't exist.
     + CategoryInfo          : NotSpecified: (:) [Get-MailboxStatistics], ManagementObjectNotFoundException
     + FullyQualifiedErrorId : [Server=AM9PR09MB4882,RequestId=97a79e6b-77a1-48f8-9a1a-32ada94a0f5a,TimeStamp=4/14/2022 6:49:24 PM] [FailureCategory=Cmdlet-ManagementObjectNotFoundExceptio
    n] FE6CA880,Microsoft.Exchange.Management.MapiTasks.GetMailboxStatistics
     + PSComputerName        : outlook.office365.com

I get the same errors above, when i pass each accepted identity parameter value for get-mailboxstatistics cmdlet

According to microsoft, this are the accepted values for identity parameter, when using get-mailboxstatistics:

 Name
 Alias
 Distinguished name (DN)
 Canonical DN
 Domain\Username
 Email address
 GUID
 LegacyExchangeDN
 SamAccountName
 User ID or user principal name (UPN)
windows-server-powershelloffice-exchange-online-itpro
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

michev avatar image
1 Vote"
michev answered bernardmwanza-0900 commented

Use the -IncludeSoftDeletedRecipients switch:

 Get-MailboxStatistics InactiveMailbox -IncludeSoftDeletedRecipients
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PS C:\Windows\system32> Get-MailboxStatistics InactiveMailbox -IncludeSoftDeletedRecipients The specified mailbox Identity:"InactiveMailbox" doesn't exist. + CategoryInfo : NotSpecified: (:) [Get-MailboxStatistics], ManagementObjectNotFoundException + FullyQualifiedErrorId : [Server=AM9PR09MB4882,RequestId=0f4d456d-f185-47d8-bd50-6f98336eebe8,TimeStamp=4/15/2022 4:50:52 PM] [FailureCategory=Cmdlet-ManagementObjectNotFoundException] 59CEA735,Microsoft.Exchange.Management.Map iTasks.GetMailboxStatistics + PSComputerName : outlook.office365.com PS C:\Windows\system32>

0 Votes 0 ·
michev avatar image michev bernardmwanza-0900 ·

Ahem, "InactiveMailbox" above refers to the identity of the mailbox you want to retrieve stat for. As in:

  Get-MailboxStatistics InactiveMailbox@domain.com -IncludeSoftDeletedRecipients


0 Votes 0 ·

Thank you so much @michev, this is what i was looking for and its working.

0 Votes 0 ·