Im having multiple requests to unlock files which have been locked by users (occasionally these files aren't even locked by that user). I have fond a powershell script to overcome the problem and I was wondering if someone could advise me on how I would use it please

Also how do I paste code into this forum? I used the code comment and it went all bold and out of format

[Site of code][1]

Testing Code
  • Type out your code, select it and then click on the curly braces in the tool bar. The coded you have referenced is for on-prem only. I'll assume by your title that you are using Office 365? – Bunzab Mar 22 '17 at 16:36
  • Hi, thanks for the reply - yes I'm O365 rather than on prem... Is there a way to sort it with a hosted solution? – Shabbaranks Mar 22 '17 at 19:44
  • Given the fact that I am using SharePoint Online - am I supposed to use Get-SPOSite to retrieve SharePoint Online commandlets? – Shabbaranks Mar 23 '17 at 9:53
  • Somebody has a solution for Office 365 Sharepoint Online to unlock file locks (Releaselock) after years? I searched hours, but get no solution for Sharepoint Online (only for sharepoint on premise). Any solution available? – Manni79 Jan 6 '19 at 19:54

I have not had to do this in SPO as of yet but looking at the Client API I'm afraid there is no equivalent. The SOM property locktype is not there and neither is the method ReleaseLock. You can have a look at the Client.File class members here.

So to answer your question it isn't possible to release locks in SPO. If it is happening to you regularly raise a support call from your tenant admin center.


You can run the code on one of the SharePoint servers as a user that has the rights to run the file and access each of the documents, such as the SharePoint Admin account. First download the file to the server in a location such as D:\scripts\ From the SharePoint Server right click 'SharePoint Management Shell' and select run as Admin. Then run the script by typing 'D:\scripts\unlock.ps1'. If you do not have access to run the script, ask your SharePoint Admin to run it for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.