Determining retention policies for all users in O365

TJG091 1 Reputation point
2021-08-18T16:13:18.52+00:00

I am running into incomplete data being returned when running the command, Get-mailbox -ResultSize Unlimited | select Name, RetentionPolicy | export-csv c:\ncs\retention-365.csv -not.

I am running this in Exchange Online Powershell to get retention policies assigned to all users

I have run the command multiple times but get different results each time. We have about 16k users in O365 and I am only getting results for 6600. Subsequent runs of the command give me results of 4500, 3800.

What am I missing?

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,369 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,901 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,389 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 96,076 Reputation points MVP
    2021-08-18T16:37:32.11+00:00

    It's likely that your PowerShell session is timing out. Try the new REST-based cmdlets, which should be more robust: https://learn.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps

    Get-EXOMailbox -ResultSize Unlimited -Properties RetentionPolicy | select Name, RetentionPolicy   
    

    You can also try running it in smaller batches, by filtering the users say per department, etc. Or simply try from a different machine/network, 16k should take just few minutes to return.