Share via

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 | 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.

Exchange | Hybrid management
Exchange | Hybrid management

The administration of a hybrid deployment that connects on-premises Exchange Server with Exchange Online, enabling seamless integration and centralized control.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

1 answer

Sort by: Most helpful
  1. Vasil Michev 125.9K Reputation points MVP Volunteer Moderator
    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.


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.