Unable to get full list of users with Legal Hold

Mani 316 Reputation points
2025-01-16T22:17:32.5933333+00:00

Hello All,

I tried this command to get all users who are placed on Holds

Get-Mailbox -ResultSize unlimited | where{$_.InPlaceHolds -ne $null} | FL DisplayName,PrimarySmtpAddress,RecipientTypeDetails,InPlaceHolds | Export-Csv -Path "C:\script

s\Holdreport.csv"-NoTypeInformation

But the csv is not showing the exact results, instaed it showing the results like the below image,

Can someone suggest what's missing here and how to get users list with Legal hold or Litigation hold enabled in my organization.

User's image

Microsoft Exchange Online
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,711 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,780 questions
{count} votes

Accepted answer
  1. Kavya 490 Reputation points
    2025-01-17T10:27:31.7433333+00:00

    Are you considering only in-place holds? You should also check for litigation and retention holds to ensure no mailboxes with other types of holds are missed.

    To export mailboxes with in-place hold,

    Get-mailbox -IncludeInactiveMailbox -ResultSize Unlimited | Where-Object { $_.InPlaceHolds -ne $Empty } | Select DisplayName, PrimarySmtpAddress, RecipientTypeDetails, InPlaceHolds | export-csv D:/hold.csv -NoTypeInformation

    To export mailboxes with litigation hold,

    Get-mailbox -IncludeInactiveMailbox -ResultSize Unlimited | Where-Object { $_.LitigationHoldEnabled -eq $True } | select Displayname,LitigationHoldDate,LitigationHoldOwner,LitigationHoldDuration | export-csv D:/hold.csv -NoTypeInformation

    If you need to export more details on different types of holds, you can try this PowerShell script: https://o365reports.com/2021/06/29/export-office-365-mailbox-holds-report-using-powershell/

    The script provides a summary report of all hold types and generates separate detailed reports for each hold type.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Xintao Qiao-MSFT 6,030 Reputation points Microsoft Vendor
    2025-01-17T02:05:14.9+00:00

    Hi, @Mani

    It looks like you're combining Format-List (FL) and Export-Csv, which is causing the issue. The Format-List cmdlet is used for displaying data in a specific format in the console, but it is not suitable for exporting data to a CSV file. You should use Select-Object instead of Format-List to select the properties you want to export. Here's the corrected command:

    Get-Mailbox -ResultSize unlimited | Where-Object {$_.InPlaceHolds -ne $null} | Select-Object DisplayName, PrimarySmtpAddress, RecipientTypeDetails, InPlaceHolds | Export-Csv -Path " C:\scripts\Holdreport.csv" -NoTypeInformation
    

    This command will properly select the desired properties and export them to the specified CSV file. Here are my test results.

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.

Your answer

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