由于某个文档库设置了编辑前签出功能,导致批量导入文件时这些文件默认的状态都被签出了。如果手动签入则费时费力,故利用PowerShell来实现批量签入Document Library中的文件。
Add-PSSnapin Microsoft.SharePoint.PowerShell
function CheckInDocument([string]$url){
$spWeb=Get-SPWeb $url
$spDocument=$spWeb.Lists.TryGetList("Documents");
Write-Host "需要签入文件的文档库:$($spDocument.Title)"
$files=$spDocument.CheckedOutFiles
Write-Host "需要签入的文件个数:$($files.Count)"
$files|where{$_.CheckOutStatus -ne "None"}|%{
$_.TakeOverCheckOut();
$docItem=$spDocument.GetItemById( $_.ListItemId);
$docItem.File.CheckIn("Administrator Check In");
Write-Host "$($docItem.File.Name) Check In" -ForegroundColor Green
}
$spWeb.Dispose();
}
CheckInDocument("http://reus");