Microsoft SharePoint 2013 - Locked File Error "File is locked by another user"

posted 10 Jul 2014, 02:47 by Tristan Self   [ updated 10 Jul 2014, 02:47 ]
PROBLEM:

You can't checkout a file because it says it is "locked by another user" or is "locked by <USERNAME>", but from the SharePoint UI you can't see who has it locked out or you can't see that it has been locked out at all.

SOLUTION:

This is a big problem with SharePoint since 2003, 2007 was the same, so was 2010 and so is 2013, so it appears to be here to stay. Microsoft say you should wait 10 minutes and the lock will be released, however this is not always the case. You could reboot the whole server (yuk) or restart IIS. Alternatively you can do the following:

1. Open the SharePoint 2013 Management Shell from the SharePoint server. You need to have Farm Administrator rights over SharePoint or Admin rights over the site collection in which the locked file is located.
2. Run the Management Shell as Administrator.
3. Then enter the following:

$w=get-spweb http://intranet.domain.com/
$f=$w.getfile("/SITENAME/LIBRARYNAME/myfile.docx")
$f

This will show you a list of properties of the file, within that you'll see that the file has a lock on it because it has a "LockID" and the user who has it locked "LockedByUser."

To unlock the file, but I found these would not work giving some odd error.

$f.releaselock($f.lockid)
$f.releaselock({theGUIDofTheLock})

So to unlock do step for:

4. Run this now:

$url = "http://intranet.domain.com/SITENAME" 
$fileurl = "http://intranet.domain.com/SITENAME/LIBRARY/myfile.docx" 
$web = Get-SPWeb $url 
$item = $web.GetListItem($fileurl) 
$item.File.CheckOutStatus
$item.ReleaseLock

Now check again using the $f and you should see the lock has gone.



Comments