Share via

Mailbox statistics script

Abhijit Kumar 0 Reputation points
2023-03-15T09:28:18.05+00:00

I am executing below script to export a detailed mailbox statistics report but it is not showing result for RecipientTypeDetails and LitigationHoldEnabled in output file. Instead it contains + Microsoft.Exchange.Management.MapiTasks.Presentation.MailboxStatistics.RecipientTypeDetails + in the output for these two fields. Can someone help.

$mbx = Get-Mailbox -ResultSize Unlimited
$head = "DisplayName,Alias,ItemCount,TotalItemSize,LastLoggedOnUserAccount,LastLogonTime,LastLogOffTime,RecipientTypeDetails,LitigationHoldEnabled"
$head | Out-File -Append MailboxReport.csv
$mbx | % {
    Write-Host -Fore Green "Processing $mbx.Name"
    $user = Get-MailboxStatistics -Identity $_.Identity
    $data = """" + $user.DisplayName + """" + "," + """" + $user.Alias + """"  + "," + """" + $user.ItemCount + """" + "," + """" + $user.TotalItemSize + """" + "," + """" + $user.LastLoggedOnUserAccount + """" + "," + """" + $user.LastLogonTime + """" + "," + """" + $user.LastLogOffTime + """"," + """" + $user.RecipientTypeDetails + """"," + """" + $user.LitigationHoldEnabled + """"
    $data | Out-File -Append .\MailboxReport.csv 
    }

Exchange Online
Exchange Online

A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.

Exchange | Exchange Server | Other
Exchange | Exchange Server | Other

A robust email, calendaring, and collaboration platform developed by Microsoft, designed for enterprise-level communication and data management.Miscellaneous topics that do not fit into specific categories.

Exchange | Exchange Server | Management
Exchange | Exchange Server | Management

The administration and maintenance of Microsoft Exchange Server to ensure secure, reliable, and efficient email and collaboration services across an organization.

Windows for business | Windows Server | User experience | PowerShell

1 answer

Sort by: Most helpful
  1. Vasil Michev 127K Reputation points MVP Volunteer Moderator
    2023-03-15T09:44:30.1166667+00:00

    Use the .ToString() method to get the property value:

    C:\> $a.RecipientTypeDetails
    PSComputerName RunspaceId Value

    -------------- ---------- -----

    outlook.office365.com 5dd98607-847b-4a4b-ab0e-6adc3c9d83d2 UserMailbox

    vs

    $a.RecipientTypeDetails.ToString()

    UserMailbox

    Rinse and repeat for any similar properties.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.