Unlock a SharePoint File with PowerShell

Ben Steginkpowershell, SharePoint 2013, SharePoint 2016Leave a Comment

File Lock

SharePoint can do some goofy things at times. Is getting an orphaned file lock within a Document Library. Fortunately you can quickly unlock a SharePoint file with PowerShell. You may see an error that is similar to:

“The file is currently checked out or locked for editing by another user” or “The file is locked for shared use by…”

What should happen is that if the file is locked, and a user is unable to check it back in or is unable to unlock it, is the file lock times out after 10 minutes. See this KB from Microsoft for details around it https://support.microsoft.com/en-us/kb/899709.

However, every once in while, things go really bad and this doesn’t work. Even though you have passed the 10 minutes (the CheckedoutExpires), the file is still locked and there is nothing you can do about it.

Unlock a SharePoint File with PowerShell

There are some articles out there suggesting you should just update the Content Database directly to fix this…DON’T DO IT!! This will leave your farm in an unsupported state.

You can actually fix this with the following PowerShell which IS supported:

Once that PowerShell has been run you can go back to the file and delete it or modify it. The file will be unlocked for modification immediately.