The file is locked for exclusive use by user... SharePoint

The file is locked for exclusive use by SharePoint
Please do not forget to comment if this helps.

Use below PS script to unlock document. (Will need farm admin access)

$web = Get-SpWeb <SP Web URL>
$item = $web.GetListItem("<Document URL including web>")
#e.g : https://my.sp.com/sites/test1/2017/myPlan.xlsx
$item.file.LockType
$item.file.LockedByUser
$item.file.LockExpires


## Unlock
$userId = $item.File.LockedByUser.ID
$user = $web.AllUsers.GetById($userId)
$impSite = New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken);
$impWeb = $impSite.OpenWeb();
$impItem = $impWeb.GetListItem("http:\\domain.FULLURL.com\FilaName.xlsx")
$impItem.File.ReleaseLock($impItem.File.LockId)


$web.dispose()
$impWeb.dispose()

Comments

Post a Comment

Popular posts from this blog

Chrome Extension to auto refresh Power BI report.

Dataverse D365 REST Web Api using client secret From Postman or Power Automate desktop (PAD) .

How to call SharePoint online rest APIs using postman?