Hello @Dmitriy Kolesnikov
Thanks for the question and using MS Q&A platform.
To retrieve the list of mailboxes associated with each retention policy in Microsoft Purview, you can use PowerShell commands to extract and format the information from the
Get-RetentionCompliancePolicy
command. TheExchangeLocation
field contains the mailboxes, but it may be truncated in the output.
Here are steps to Retrieve Full List of Mailboxes for a Retention Policy:
Open PowerShell - Make sure you have the necessary permissions, and the Exchange Online Management module installed.
Connect to Exchange Online - If you haven't already connected to your Exchange Online environment, you can do so with the following command:
Connect-ExchangeOnline -User PrincipalName <your-admin-username>
Retrieve Retention Policies - Use the Get-RetentionCompliancePolicy
command to get the retention policies and their properties.
$policies = Get-RetentionCompliancePolicy
Extract Mailboxes - Loop through each policy and extract the ExchangeLocation
field. You can use the -ExpandProperty
parameter to get the full list of mailboxes.
powershellVerifyOpen In EditorRunCopy code
Explain
1foreach ($policy in $policies) {
2 $policyName = $policy.Name
3 $mailboxes = $policy.ExchangeLocation -join ", "
4 Write-Output "Policy Name: $policyName"
5 Write-Output "Mailboxes: $mailboxes"
6 Write-Output "-----------------------------"
7}
Hope this helps. Do let us know if you any further queries.