When we set the version limit on the Organization level to be 100 versions, how we can apply this to existing libraries

john john Pter 505 Reputation points
2025-02-19T20:56:45.7133333+00:00

We want to Apply the Version limit on the Organization limit, as follow:-

DdBP6tD4

Where each document will have maximum of 100 versions as long as the version was not created 10 years ago.

now this will be applied to new libraries inside new sites or inside existing sites. but what about existing libraries inside existing sites? how we can apply the same Organization settings to them?

Thanks

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,321 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenXu-MSFT 23,816 Reputation points Microsoft Vendor
    2025-02-20T06:14:06.94+00:00

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.