Hi @john john Pter,
For existing Libraries in existing Sites, you can update Version Limits via PowerShell:
Use PowerShell with PnP modules to iterate through all sites and libraries, updating version settings.
# Connect to SharePoint Admin Center
Connect-PnPOnline -Url https://yourtenant-admin.sharepoint.com -Interactive
# Get all site collections
$sites = Get-PnPTenantSite
foreach ($site in $sites) {
Connect-PnPOnline -Url $site.Url -Interactive
$libraries = Get-PnPList | Where-Object { $_.BaseType -eq "DocumentLibrary" -and $_.Hidden -eq $false }
foreach ($lib in $libraries) {
# Enable versioning if not already enabled
Set-PnPList -Identity $lib.Id -EnableVersioning $true
# Set major version limit to 100 (adjust for minor versions if needed)
Set-PnPList -Identity $lib.Id -MajorVersionLimit 100
}
}
And create a retention policy in the Microsoft 365 Compliance Center to delete content older than 10 years based on the "Created date" of versions. Then apply to all libraries.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.