Sharepoint 2010 - Enable Versioning for all Document Libraries

I am in the process of setting up a new intranet based on Microsoft SharePoint 2010 (existing server). I have added many document libraries and have now discovered I need to go back and enable versioning for all of them.

https://social.technet.microsoft.com/Forums/office/en-US/ae67e3a6-d2a4-4253-ad86-4a5ebca313ae/2010-sharepoint-global-setting-for-document-library-version-control?forum=sharepointadminprevious

I see by the last comment on this post that there is a way to do this with a PowerShell script.

How is this done?
street9009Asked:
Who is Participating?
 
martushaProduct managerCommented:
Hello street9009,

you need to modify that code according your need (for example, minor version - false).
How to run powershell scripts

Edit: I have found another article which better explane how to enale major versioning, and the script there is much easier. Please look here:
http://blogs.c5insight.com/Home/entryid/493/Use-PowerShell-to-Enable-Versions-in-All-Document-Libraries-in-All-Subsites
0
 
Rainer JeschorCommented:
Hi,
this script will enable versioning in all document libraries:
$topweb = Get-SPWeb http://intranet.yoursharepoint.com/sites/xyz 
$subsites = $topweb.webs 
Foreach ($subsite in $subsites) 
{ 
  Write-Host "Web = " $subsite 
  foreach ($lib in $subsite.Lists) { 
    if ($lib.BaseTemplate -eq "DocumentLibrary") {
      Write-Host "Updating Library = " $lib 
      # Enable Versioning 
      $lib.EnableVersioning = $true 
      $lib.Update() 
    } 
   } 
   $subsite.Dispose() 
}

Open in new window

HTH
Rainer
0
 
street9009Author Commented:
Doesn't appear to have worked. I set the top web address to the address we use to access, saved, and ran, but when I check the document libraries, they're still set to "No Versioning".
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

 
Rainer JeschorCommented:
Hi,
could you perhaps describe your site / web / subweb / document libraries structure?
Which kind of versioning do you want to enable? Major only, Major +minor version?
Thanks.
Rainer
0
 
street9009Author Commented:
Our site has multiple sub-sites and intranet is one of them. We access by going to http://<SERVERNAME>/<SUBSITE>. So in this case, http://<SERVERNAME>/intranet.

How do the version numbers actually get created? I think we would need minor as our users are just going to open a document, select "Edit", do their edits, and Save. I don't know how those version numbers are determined.
0
 
martushaProduct managerCommented:
"Most organizations use minor versions when files are under development, and major versions when certain milestones are reached or when the files are ready for review by a wide audience. In many organizations, draft security is set to allow only the owner of a file and people who have permissions to approve files. That means that minor versions cannot be seen by anyone else until a major version is published."
More on Introduction to versioning: https://support.office.com/en-za/article/Introduction-to-versioning-49e87cfa-1f18-427b-852b-7ff1612ef672
0
 
street9009Author Commented:
I think major versions is what I want, after having used the site that we're working on in this question.
0
 
martushaProduct managerCommented:
0
 
street9009Author Commented:
Hello martusha,

One of the solutions points to a dead link (it has some code in it but no explanation for how to use) and the other doesn't give any solution other than to "use Powershell", which we already know.

Can you explain how to use the code provided there?
0
 
street9009Author Commented:
Hey martusha,

That's the one posted above and I remember reviewing that page before as well. For some reason, it didn't work. I did modify the web address on the first line but when I run it with PowerShell (either by right-clicking and choosing "Run with PowerShell" or by opening the SharePoint 2010 Management Shell, browsing to it, and running with a .\) it fails. When I run it from the command line I see the error:

C:\Users\administrator.MEMCO1\desktop\EnableVersioning.ps1 : Exception has been
 thrown by the target of an invocation.
At line:1 char:23
+ .\EnableVersioning.ps1 <<<<
    + CategoryInfo          : NotSpecified: (:) [EnableVersioning.ps1], Target
   InvocationException
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Enab
   leVersioning.ps1

Open in new window


I am running this from the SharePoint server.
0
 
martushaProduct managerCommented:
however the only problem is that you don’t have enough permissions on the Site or Web in question. Even if you are a farm admin and local admin on the server, some SharePoint PowerShell Commands will not allow you to run at the SITE or Web level.

Easiest way to fix it, since you already have access to the server, give yourself Full Control at the Web Application Level (in User Policy) and you shouldn’t have this problem anymore!

All permissions required to correct this error:
•Site Collection administrator on the SPSite (whether given through Central Admin or Site Settings)
•PowerShell scripting admin: add-spshelladmin domain\username
•PowerShell scripting admin on the content databases: get-spcontentdatabase | add-spshelladmin domain\username
0
 
street9009Author Commented:
Worked like a charm. Thank you!
0
 
martushaProduct managerCommented:
Nice! Have a great day!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.