如何在SharePoint中Release Check out 状态的文件

最近收到客户问题用户无法编辑SharePoint中某个文件,因为此文件被其他人check out了。但是很多时候无法联系到check outuser执行checkin,此时需要在Server端进行releasefile

如何在SharePoint中Release Check out 状态的文件

 

对于这类需求可以通过如下Script实现:

如何在SharePoint中Release Check out 状态的文件

 

$webUrl='Site Collection URL'

$fileUrl='File URL'

$w =get-spweb $webUrl

$l =$w.lists['Library Name']

$f =$w.GetFile($fileUrl)

$i =$l.GetItemById($f.Item.Id)

$s =New-Object Microsoft.SharePoint.SPSite($w.site.id,$i.File.LockedByUser.UserToken)

$w =$s.OpenWeb($w.id)

$l =$w.lists['Library Name']

$i =$l.GetItemById($f.Item.Id)

$i.File.CheckOutStatus

$i.File.Undocheckout()

 

执行完成后刷新Browser查看当前file的状态,文件被release成功。

如何在SharePoint中Release Check out 状态的文件

 

 

感谢阅读。