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

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

Machine generated alternative text:Publishing Feature TestPublishing Feature Testœ¿9 New ± Upload ç;y Sync () ShareAll DocumentsFindafileMore ‘d‘ð fl NameFile Size ModifiedModified ByChecked Out ToiJjj Deletion_2017-07-19T112100 U... 19933 AboutanhouragoSystem Account • Vi TingtingDrag files here to upload

 

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

 

$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成功。

Machine generated alternative text:Publishing Feature TestPublishing Feature TestNew ‘t Upload  Sync Q Share More ‘All Documents ••• Find a file J)“ Ii Name File Size Modified Modified By Checked Out ToÓJi Deletion_2017-07-19T112100 * ... 19933 About an hour ago System AccountDrag files here to upload

 

 

感谢阅读。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值