Last updated on December 7th, 2016 at 03:58 pm

Versioning is a great SharePoint feature that allows for life’s little mistakes to be forgiven.  However, if not configured with care versioned documents can quickly consume significant amounts of space in your content databases.  If you have many people that can configure document library properties, this can become a major issue as each person may have their own idea about appropriate versioning settings.

The following script will perform the following actions against a SharePoint farm:

  • Crawl all web applications
  • For each web application, crawl all lists
  • For each list, check to see if versioning is enabled
  • If versioning is enabled, check the Major Version Limit
  • If the Major Version Limit is not set to 3, make it 3
  • If the Major Version limit is changed, update all list items and trim excessive versions

I wrote this script to help combat a single ballooning site collection content database.  After running the script, said content database was reduced by 20 GB. Enjoy!