Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
Manage version history limits for a library using PowerShell
Follow these steps to manage version history limits for a site by using PowerShell.
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.
Connect to SharePoint as a SharePoint Administrator in Microsoft 365. To learn how, see Getting started with SharePoint Online Management Shell.
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 $libNameSet Automatic version history limits on a library To set the default version history limit to automatic: Set-SPOListVersionPolicy -Site $siteUrl -List $libName -EnableAutoExpirationVersionTrim $true
Supply-FileTypesparameter with an array of file types to set their version history limit to automatic:Set-SPOListVersionPolicy -Site $siteUrl -List $libName -EnableAutoExpirationVersionTrim $true -FileTypes @("file type 1", "file type 2")Set Manual limits with count and time parameters on a library To set Manual limits for default version history limit with count and time parameters: Set-SPOListVersionPolicy -Site $siteUrl -List $libName-EnableAutoExpirationVersionTrim $false-MajorVersionLimit <delete major versions exceeding limit>-MajorWithMinorVersionsLimit <number of major versions for which all minor versions will be kept>-ExpireVersionsAfterDays <delete versions exceeding time limit set in days>
Supply-FileTypesparameter with an array of file types to set their version history limit to Manual limits with count and time parameters:Set-SPOListVersionPolicy -Site $siteUrl -List $libName-EnableAutoExpirationVersionTrim $false-MajorVersionLimit <delete major versions exceeding limit>-ExpireVersionsAfterDays <delete versions exceeding time limit set in days>-FileTypes @("file type 1", "file type 2")Set Manual limits with count with no expiration limit on a library To set Manual limits for default version history limit with count parameter only: Set-SPOListVersionPolicy -Site $siteUrl -List $libName-EnableAutoExpirationVersionTrim $false-MajorVersionLimit <delete major versions exceeding limit>-MajorWithMinorVersionsLimit <number of major versions for which all minor versions will be kept>-ExpireVersionsAfterDays 0
Supply-FileTypesparameter with an array of file types to set their version history limit to Manual limits with count parameter only:Set-SPOListVersionPolicy -Site $siteUrl -List $libName-EnableAutoExpirationVersionTrim $false-MajorVersionLimit <delete major versions exceeding limit>-ExpireVersionsAfterDays 0-FileTypes @("file type 1", "file type 2")Sync the library version history limits to its parent site To fully sync the version history limits:
Set-SPOListVersionPolicy -Site $siteUrl -List $libName -Sync
Append-ExcludeDefaultPolicyto sync only the file type version history limits and exclude the default:
Set-SPOListVersionPolicy -Site $siteUrl -List $libName -Sync -ExcludeDefaultPolicy
Supply an array to the-FileTypesparameter to sync the select file type version history limits:
Set-SPOListVersionPolicy -Site $siteUrl -List $libName -Sync -FileTypes @("<file type 1>", "<file type 2>")
Supply an empty array to the-FileTypesparameter to sync only the default version history limits:
Set-SPOListVersionPolicy -Site $siteUrl -List $libName -Sync -FileTypes @()
Learn More
For more information, check out the following resources:
- File Type Version Limits
- View version history limits for a library using Set-SPOListVersionPolicy
- Manage version history limits for a library using Set-SPOListVersionPolicy