1

Being a designer, I perform a lot of changes on a SP page, small ones and big ones and thus I save a lot. Each save is a major version (company policy) and in no time, I reach the default 500 version limit. I do a lot of cleansing, deleting previous versions when a page is more or less 'ready'.

I probably can change the 500 limit of the library in the library properties when I reach it, but I was wondering if there is a way to start re-counting from a specific point/major version?

  • 1
    Disabling and re-enabling it doesnt work? – SharePointMan Jun 22 '17 at 14:09
  • Had tried that, but page keeps showing the last version number. Thanks for the script. Will try it out, but need to pass thru our company's IT to get access to Powershell :-( Might be problematic since we are using SP online. – Murphy Jun 23 '17 at 13:47
2

I think below powershell should help you reset the version numbers of all the items. Try this in your dev env.

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
# 2 variables which need to be set
$siteCollection = "http://SharePoint/Sites/SiteCollection"
$documentRetentionCount=10

# get site collection
$site = new-object Microsoft.SharePoint.SPSite($siteCollection)

# loop through each subsite
foreach ($web in $site.AllWebs)
{
   write-host $web.url

   # loop through all lists in each subsite
   foreach ($list in $web.Lists)
   {
      # examine if BaseType of list is a Document Library and if versioning is turned on
      if (($list.BaseType -eq "DocumentLibrary") -and ($list.EnableVersioning))
      {
         # Set the Major version limit to keep the latest 10 versions
         $list.MajorVersionLimit = $documentRetentionCount
         $list.Update()
         foreach($item in $list.Items)
         {# Perform a system update on each item 
            $item.SystemUpdate($true)
         }
      }
   }
}
$web.Dispose();
$site.Dispose();

Ref This

|improve this answer|||||
  • Did it work for you Murphy? Did you have to change anything? Thank you! – Yugo Oct 5 '18 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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