0

I am have a file and a folder in two separate document libraries that I am experiencing similar issues with. They are both locked (I didn't even know folders could be locked) and I cannot unlock them.

The folder doesn't tell me who it is locked by but it is empty and I want to delete it but can't because it says:

The file is currently checked out or locked for editing by another user. 

Similarly I want to move a file in another doc library but cannot because it says:

The file https://my-path/my-file.docx is locked for shared use by cdn\user1.

I have spoken with the user and he does not have the file open anymore and also get the same error I get when he tries to checkout the file. Neither the file nor the folder are checked out, they are just locked and I can't do anything with them. I have read about this "10 minute write lock" but waiting 10 minutes does not resolve my issue, it's been several days and the locks are not going away.

Any help would be greatly appreciated.

0

Approach 1:

$web = Get-SPWeb http://web;  
$list = $web.Lists["Library"];  
$item = $list.Items | ? {$_.ID -eq "Item"};   
$file = $item.File;  
$file.ReleaseLock($file.LockId)

Approach 2 (if first isn't working or throwing an exception):

$web = Get-SPWeb http://web  
$list = $web.Lists["Library"]  
$item = $list.Items.GetItemById(1)

$userId = $item.File.LockedByUser.ID  
$user = $web.AllUsers.GetById($userId)

# impersonation
$iSite = New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken);  
$iWeb = $iSite.OpenWeb();  
$iList = $iWeb.Lists[$list.Title];  
$iItem = $iList.GetItemById($item.ID);  
$iItem.File.ReleaseLock($iItem.File.LockId);  

# Dispose at end
$iWeb.Dispose();  
$iSite.Dispose();  
$web.Dispose()

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.