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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
How the Cloud Can Help You as an MSSP

Today, every Managed Security Service Provider (MSSP) needs a platform to deliver effective and efficient security-as-a-service to their customers. Scale, elasticity and profitability are a few of the many features that a Cloud platform offers. Register today to learn more!

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.