Frage

there is a file I want to delete but it is locked. I see with powershell that the lock type is Shared.

>$item = $web.GetListItem('pathtomyfile')
>$item.file.locktype
>Shared

Can I change or remove the locktype with Powershell?

War es hilfreich?

Lösung

Following is the powershell script for removing/releasing lock from any document from SharePoint

$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)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top