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

Benard Mwanza 1,001 Reputation points
2022-04-15T15:17:06.58+00:00

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)
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,386 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 100.2K Reputation points MVP
    2022-04-15T15:27:35.68+00:00

    Use the -IncludeSoftDeletedRecipients switch:

    Get-MailboxStatistics InactiveMailbox -IncludeSoftDeletedRecipients
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful