Skip to main content
added 86 characters in body
Source Link
pholpar
  • 3.2k
  • 1
  • 15
  • 14

You should be able to release such orphaned locks via impersonating the user first, as described at the end of this post: http://pholpar.wordpress.com/2014/04/03/how-to-use-powershell-to-delete-short-term-locks-from-documents-opened-from-sharepoint/

For example, using PowerShell:

$web = Get-SPWeb http://intranet.contoso.com
$list = $web.Lists["DocLib"] 
$item = $list.GetItemById(2) 
$file = $item.File 
$userId = $file.LockedByUser.ID 
$user = $web.AllUsers.GetByID($userId) 
$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken); 
$impWeb = $impSite.OpenWeb(); 
$impList = $impWeb.Lists[$list.Title] 
$impItem = $impList.GetItemById($item.ID) 
$impFile = $impItem.File 
$impFile.ReleaseLock($impFile.LockId)

After the lock has been released, you should be able to delete the document again.

You should be able to release such orphaned locks via impersonating the user first, as described at the end of this post: http://pholpar.wordpress.com/2014/04/03/how-to-use-powershell-to-delete-short-term-locks-from-documents-opened-from-sharepoint/

For example, using PowerShell:

$web = Get-SPWeb http://intranet.contoso.com
$list = $web.Lists["DocLib"] 
$item = $list.GetItemById(2) 
$file = $item.File 
$userId = $file.LockedByUser.ID 
$user = $web.AllUsers.GetByID($userId) 
$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken); 
$impWeb = $impSite.OpenWeb(); 
$impList = $impWeb.Lists[$list.Title] 
$impItem = $impList.GetItemById($item.ID) 
$impFile = $impItem.File 
$impFile.ReleaseLock($impFile.LockId)

You should be able to release such orphaned locks via impersonating the user first, as described at the end of this post: http://pholpar.wordpress.com/2014/04/03/how-to-use-powershell-to-delete-short-term-locks-from-documents-opened-from-sharepoint/

For example, using PowerShell:

$web = Get-SPWeb http://intranet.contoso.com
$list = $web.Lists["DocLib"] 
$item = $list.GetItemById(2) 
$file = $item.File 
$userId = $file.LockedByUser.ID 
$user = $web.AllUsers.GetByID($userId) 
$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken); 
$impWeb = $impSite.OpenWeb(); 
$impList = $impWeb.Lists[$list.Title] 
$impItem = $impList.GetItemById($item.ID) 
$impFile = $impItem.File 
$impFile.ReleaseLock($impFile.LockId)

After the lock has been released, you should be able to delete the document again.

Source Link
pholpar
  • 3.2k
  • 1
  • 15
  • 14

You should be able to release such orphaned locks via impersonating the user first, as described at the end of this post: http://pholpar.wordpress.com/2014/04/03/how-to-use-powershell-to-delete-short-term-locks-from-documents-opened-from-sharepoint/

For example, using PowerShell:

$web = Get-SPWeb http://intranet.contoso.com
$list = $web.Lists["DocLib"] 
$item = $list.GetItemById(2) 
$file = $item.File 
$userId = $file.LockedByUser.ID 
$user = $web.AllUsers.GetByID($userId) 
$impSite= New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken); 
$impWeb = $impSite.OpenWeb(); 
$impList = $impWeb.Lists[$list.Title] 
$impItem = $impList.GetItemById($item.ID) 
$impFile = $impItem.File 
$impFile.ReleaseLock($impFile.LockId)