Set version limits for individual document library (Preview)

The default version history limits for new document libraries are set by either the organization-level limits or the site-level limits. If the site has its own version history limit, it means the site breaks inheritance from the organization. However, to meet specific content requirements, site admins can decide to configure versioning for a library.

Here's a summary of the expected behavior when document libraries version expiration or count limits are updated:

  • When library level version expiration setting is updated, the new expiration limit is applied to newly created versions only. Take an example of a library with version expiration settings updated from Never Expire to Expire after six months. New version created is set to expire after six months with no impact on versions that is already created.

  • When library level count limits are updated, if existing versions exceed the new count limit, then those versions are gradually trimmed when the file is updated. Consider a library where the version count limit is initially set to 500 versions but is later reduced to 300 versions. In this scenario, if there's a file with 500 versions, each time a user updates the file, the system gradually purges the oldest 20 versions with each new version creation until the total number of versions aligns with the updated limit of 300. It's crucial to note that when count limits are lowered, the process of version deletion occurs gradually, with up to 20 versions being removed for every new version created.

Screenshot of overwrite version history.

Manage version history limits for a library using PowerShell

Follow these steps to manage version history limits for a site by using PowerShell.

  1. Download the latest SharePoint Online Management Shell.

    Note

    If you installed a previous version of the SharePoint Online Management Shell, go to Add or remove programs and uninstall SharePoint Online Management Shell.

  2. Connect to SharePoint as a SharePoint Administrator in Microsoft 365. To learn how, see Getting started with SharePoint Online Management Shell.

  3. Run one of the following commands to manage version history limits on a library:

Action PowerShell Command
View version history limits set on a library Get-SPOListVersionPolicy -Site $siteUrl -List $libName
Set Automatic version history limits on a library Set-SPOListVersionPolicy -Site $siteUrl -List $libName -EnableAutoExpirationVersionTrim $true
Set Manual limits with count and time parameters on a library Set-SPOListVersionPolicy -Site $siteUrl -List $libName
-EnableAutoExpirationVersionTrim $false
-MajorVersionLimit <delete major versions exceeding limit>
-MajorWithMinorVersionsLimit <delete minor versions exceeding limit>
-ExpireVersionsAfterDays <delete versions exceeding time limit set in days>
Set Manual limits with count with no expiration limit on a library Set-SPOListVersionPolicy -Site $siteUrl -List $libName
-EnableAutoExpirationVersionTrim $false
-MajorVersionLimit <delete major versions exceeding limit>
-MajorWithMinorVersionsLimit <delete minor versions exceeding limit>
-ExpireVersionsAfterDays 0

Learn More

For more information, check out the following resources: