PowerShell How to bulk check in files in the SharePoint document library

Source: Internet
Author: User

Because a document library has the edit checkout feature set, the default state of the files is checked out when the files are bulk imported. If the manual check-in is time-consuming and laborious, the PowerShell is used to implement the bulk check-in documents in the document library.

Resolution

Add-pssnapin Microsoft.SharePoint.PowerShell  
      
function Checkindocument ([string] $url) {  
          
    $spWeb =get-spweb $ URL  
      
    $spDocument = $spWeb. Lists.trygetlist ("Documents");  
      
    Write-host Document library to check in Files: $ ($spDocument. Title) "
      
    $files = $spDocument. Checkedoutfiles  
      
    Write-host" The number of files that need to be checked in: $ ( $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");

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/web/sharepoint/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.