Can we define a default value for the number of major versions inside our SharePoint libraries, that get applied to new and existing libraries

john john 946 Reputation points

When we create a new SharePoint site and/or new document libraries, they will have their number of default major versions to 500

User's image

so is there a way to change this number to be 50 instead of 500 and apply this settings to new and existing libraries ?


A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,224 questions
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.
2,792 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yanli Jiang - MSFT 23,661 Reputation points Microsoft Vendor

    Hi john ,

    Welcome to Q&A forum!

    Yes, you can set the default major version for the entire site through PowerShell. SharePoint in Microsoft 365 Library Settings allows a range of 100-50000 major versions, you can choose within this range. Then run the following PowerShell in the SharePoint Online Management Shell as an admin:

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    #Import SharePoint Online PowerShell Module
    Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
    Function Set-SPOSiteVersionHistoryLimit()
            [Parameter(Mandatory=$true)] [string] $SiteURL,
            [parameter(Mandatory=$false)][int]$VersioningLimit = 100
        Try {
            #Get Credentials to connect
            $Cred= Get-Credential
            #Setup the context
            $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
            $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)       
            #Get All Lists from the Web
            $Lists = $Ctx.Web.Lists
            #Array to exclude system libraries
            $SystemLibraries = @("Form Templates", "Pages", "Preservation Hold Library","Site Assets", "Site Pages", "Images",
                                "Site Collection Documents", "Site Collection Images","Style Library")
            #Get All document libraries
            $DocumentLibraries = $Lists | Where {$_.BaseType -eq "DocumentLibrary" -and $_.Hidden -eq $False -and $_.Title -notin $SystemLibraries}
            #Set Versioning Limits
            ForEach($Library in $DocumentLibraries)
                #Get the Library's versioning settings
                #powershell to set limit on version history
                    #Set versioning limit
                    $Library.MajorVersionLimit = $VersioningLimit
                    Write-host -f Green "Version History Settings has been Updated on '$($Library.Title)'"
                    Write-host -f Yellow "Version History is turned-off at '$($Library.Title)'"
        Catch {
            Write-host -f Red "Error:" $_.Exception.Message
    #Call the function to set version history limit
    Set-SPOSiteVersionHistoryLimit -SiteURL ""

    In the test, the value I filled in is 100, and the result is as follows:



    Note: please select the appropriate number of versions according to your needs, so as not to take up a lot of memory in the version history and affect the performance of the site.

    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.