office 365 – Automatic inclusion of newly created SharePoint site in existing retention policy

You can’t automatically add new sites explicitly to the retention policies out-of-the-box.

One way to automate it is to script this with PowerShell. I’m including all PowerShell commands you’ll need to complete this task.

Get a list of SharePoint Online sites

Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser
Get-SPOSite -Limit ALL

Install the Exchange Online PowerShell Module

Install-Module ExchangeOnlineManagement -Scope CurrentUser

Establish a new session


Get existing retention policies

Get-RetentionCompliancePolicy -Identity "SharePoint Retention Polocy" -DistributionDetail

Add a new site to the retention policy

Set-RetentionCompliancePolicy -Identity "SharePoint Retention Polocy" -AddSharePointLocation ""