$impSite and $impWeb in the above example are SPSite and SPWeb objects using the impersonated user token.Now just copy the text below and paste it into your OFF $impItem = $impList.GetItemById($item.ID) $impSite = New-Object ($web.Url, $user.UserToken) 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. you can try using impersonation to release the lock. If you run the above Powershell and still run up against an error like this.Įxception calling "ReleaseLock" with "1" argument(s): "The file XXXXXXX is locked for exclusive use by XXXXX" Use impersonation if necessary to release the lock You'll need to load the PS snapin for SharePoint cmdlets such as get-spweb, unless you use the SharePoint Management Shell installed with SharePoint, which starts a Powershell session with the SharePoint snapins already loaded. This Powershell should be executed from a web front end server on your SharePoint farm. 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(). The Powershell for removing a file lock is as follows: $web = get-spweb " $list = $web.Lists 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. With Office products, the file lock is supposed to expire automatically after ten minutes, and this is usually the case. (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.
EXCEL FILE LOCKED FOR EDITING BY ME WINDOWS 10 UPDATE
Can Powershell clear those values so the file can be edited?įor the benefit of future generations, a file lock can be removed via Powershell on an on-premises installation of SharePoint 2010 or later.įiles can get locked when a client application fails to update the server-side file token that indicates whether a file is currently being edited. Is there something that can be done to clear this file lock? These are critical documents being affected by this. We've had the user check the document out and check it back it, this has not cleared the lock.I've tried checking it out and checking it in via content and structure, fails to release the lock.I've tried to delete it in SPD as some posts reference - doesn't work, and says it's checked out.I've tried taking ownership of the file - this failes as the item doesn't show as being check out.It will say it is set to expire on 8/8/12 11:00 PM then coming in this morning when the lock should hgave expired, it is extended to 1:05 pm today. SharePoint Manager shows it is checked out by a user and the short term lock on the file is always changing. This is preventing others from updating the file or deleting it and replacing it. I've got several files in a couple document libraries in a MOSS 2007 site collection that are locked by someone when they no longer have the file checked out. I've come up against a problem I've been unable to solve, and based on my 2 days of Binging around, I've yet to find a solution to fix the problem the same with a slew of others.