Document Library Versioning settings using Powershell
In the past I had a couple of cases where users received the
following error message:
“Document is locked for editing by another user”
Some common issues which comes depending on Client machines.
Please refer: https://blogs.technet.com/b/the_microsoft_excel_support_team_blog/archive/2011/05/02/file-is-locked-for-editing-by-another-user.aspx
But in this post we will see the issue where the issue comes
only with Minor versions published in Document libraries in SharePoint 2010:
Symptoms:
-
Document Library settings
- Word/Excel/Office doc uploaded to a Document
Library and published with Major Version
1 by user1
- User1 again check out and check-in publish a
minor version 1.1
- User2 opens the file as Read-only and tries to Check
out the document from Office application. User 2 receives an error ““Document
is locked for editing by another user
Workarounds :
Workaround 1:
Change the setting of document library to allow readers to
see draft items
If you have multiple document libraries, use the below
script to make the changes for complete web application:
Note : Copy and Paste (Do not create a PS1)
function MyCustomPermission()
{
foreach ($web in (Get-SPSite -Limit All
| Get-SPWeb -Limit All))
{
Write-Host
“Processing Web: $($web.Url)…”
foreach ($list
in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]}))
{
Write-Host
“`tProcessing List: $($list.RootFolder.ServerRelativeUrl)…”
$list.EnableModeration
= $true;
$list.EnableVersioning = $true;
$list.EnableMinorVersions = $false;
$list.MajorWithMinorVersionsLimit = 0;
$list.MajorVersionLimit = 0;
$list.ForceCheckout = $true;
$list.DraftVersionVisibility = 0;
$list.Update();
}
$web.Dispose();
}
}
-
Press Enter
-
Type “MyCustomPermission”
(This will call the function that we have
defined in above script)
The PowerShell script
can be used to make changes to Document libraries. You can make changes to the Properties
defined in the above script based on your requirement.
Workaround 2:
Checkout the document from SharePoint site and then edit the
document. Issue is only when you try to checkout from Office Application.
These are the identified workarounds but permanent fix
should be released n coming Cumulative Updates for SharePoint 2010.
Hope this will help!