4

Master database has more than 500 items that have more than 10 item versions. Some content items have more than 100 versions.

According to recommendation to limit 10 item versions I want to perform a one time deletion of old versions, and keep only 10 recent versions.

I'm planning to use Sitecore Powershell that I found here:

New-UsingBlock(New-Object Sitecore.Data.Events.EventDisabler) {
    Remove-ItemVersion -Path master:\content\home -Language "en" -MaxRecentVersions 10
}

My concern is that I might be deleting item versions that are currently published to the web database. For example, version 11 is published and latest 10 versions are not yet published. Is this possible? If so, how can I enhance the script to make sure I do not delete versions that are published?

Thank you

0

1 Answer 1

5

Consider retrieving the list of candidates for removal, comparing with the web database, then remove. This SSE answer provides a sample script at comparing version between master and web and showing as a report.

When it comes to publishing, only the latest publishable version will be in the web database, not all 10.

A possible script workflow could be the following:

  • Get all the items that I care about for cleanup
  • Filter out items with fewer than 10 versions
  • Check the latest version on the item and compare with the version in web
  • If the latest version in master is publishable, then you can assume that a successful publish will push it to web
  • If the latest version matches in both master/web then you can safely assume that the cleanup will retain the version you desire

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.