Fork me on GitHub

PowerShell 批量签入SharePoint Document Library中的文件

由于某个文档库设置了编辑前签出功能,导致批量导入文件时这些文件默认的状态都被签出了。如果手动签入则费时费力,故利用PowerShell来实现批量签入Document Library中的文件。

Resolution

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");

 

posted @ 2014-06-10 20:22  木宛城主  阅读(803)  评论(1编辑  收藏  举报
multifunction lasers
访问人数