question

Romilabaretto-0689 avatar image
0 Votes"
Romilabaretto-0689 asked AllenXu-MSFT commented

Sharepoint 2016 co-authoring not working

Hi ,

Co-authoring suddenly stopped working and it gives a locked out error for multiple users while editing a powerpoint file.

Error is " The file is locked for editing by username ".

Do you want to view a read only copy?

Edit the file and merge the changes with the server when it becomes available.

All users editing the file have the same version of powerpoint installed
Cleared upload center( no items cached)
Cleared officefilecache as well but no luck.

Please advise

office-sharepoint-server-administration
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AllenXu-MSFT avatar image
0 Votes"
AllenXu-MSFT answered AllenXu-MSFT commented

Hi @Romilabaretto-0689 ,

A file lock can be removed via Powershell on an on-premises installation of SharePoint 2016.

  • How can this happen?

Files can get locked when a client application fails to update the server-side file token that indicates whether a file is currently being edited. (This type of lock is application-specific, and thus different from the explicit Check In/Check Out functionality provided by SharePoint document libraries.) This scenario comes up when computers (or applications) crash unexpectedly, or get disconnected from the network.

With Office products, the file lock is supposed to expire automatically after ten minutes, and this is usually the case. Sometimes a lock seems to persist, which may be the result of browser caching problems or bugs in the way client applications handle the file locks.

  • How can we fix it?

The Powershell for removing a file lock is as follows, run it using the SharePoint Mangement Shell as an aministrator:

 $web = get-spweb "http://sp/sitename/"
 $list = $web.Lists["LibraryName"]
 $item = $list.Items.GetItemById(2)
 $item.File.ReleaseLock($item.File.LockId)
 $web.Dispose()

Replace the placeholders with values appropriate to your environment/list/document; use the actual subsite URL in the get-spweb cmdlet, use the library's title to retrieve it from the $web.Lists collection, and use the actual ID of the problem document as the parameter in GetItemById().

  • Use impersonation if necessary to release the lock

If you run the above Powershell and still run up against an error like this:

Exception calling "ReleaseLock" with "1" argument(s): "The file XXXXXXX is locked for exclusive use by XXXXX"

You can try using impersonation to release the lock. This is accomplished by using the LockedByUser property of the file to get a reference to the user you need to impersonate, then creating a new SPSite object instance passing in that user's token as a second parameter.

 $web = get-spweb "http://sp/sitename/"
 $list = $web.Lists["LibraryName"]
 $item = $list.Items.GetItemById(2)
    
 $userId = $item.File.LockedByUser.ID
 $user = $web.AllUsers.GetById($userId)
    
 $impSite = New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken);
 $impWeb = $impSite.OpenWeb();
 $impList = $impWeb.Lists[$list.Title];
 $impItem = $impList.GetItemById($item.ID);
 $impItem.File.ReleaseLock($impItem.File.LockId)
    
 $impWeb.Dispose()
 $impSite.Dispose()
 $web.Dispose()

If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AllenXu-MSFT : Thanks for your response . I tried this command but the parameters Lockeid , LockedByUser are blank.

Please advise

0 Votes 0 ·

@Romilabaretto-0689 ,

Kindly share here the error messgae when running the PowerShell commands :-)

0 Votes 0 ·

@AllenXu-MSFT :Error message : The operation on the file cannot be completed because the specified lock arguments is not valid
$item.File.ReleaseLock($item.File.LockId)

But i even checked the parameter status which is blank.

0 Votes 0 ·

Did you use the actual ID of the problem document as the parameter in GetItemById()? You have to replace 2 in $item = $list.Items.GetItemById(2) with the actual ID of your problem document.

0 Votes 0 ·

yes i replaced it with the actual id

0 Votes 0 ·
Show more comments