Set an expiry date for the version limit on a library, did not set any expiry date for exsisting versions

john john Pter 1,015 Reputation points
2025-04-01T19:13:32.94+00:00

I use to have this settings for a document library version limits:-

User's image

now i run this script to minimize the versions numbers and set an expiry date:-

Set-SPOSite -Identity https://****.sharepoint.com -EnableAutoExpirationVersionTrim $false -MajorVersionLimit 15 -MajorwithMinorVersionsLimit 10 -ExpireVersionsAfterDays 300

but on a document, i uploaded a new version, and i noted that the expiry date only get applied to the version created after running the above script, but old versions did not have any expiry date:-

User's image

so how i can set an expiry date for old versions?

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,572 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,441 Reputation points Microsoft External Staff
    2025-04-02T02:45:32.09+00:00

    Hi @john john Pter,

    Currently there is no such function to set an expiry date for old versions. As mentioned by the offical document, it's an expected behavior

    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.

    As a workaround, you could manually delete the old version. Or you can just leave the old version, and SharePoint will auto delete oldest versions when existing versions exceed the count limit. Here is the document for more details:

    https://learn.microsoft.com/en-us/sharepoint/library-version-limits


    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.