sharepoint-2010documentcheckoutbulkcheckin

How to bulk check in all checked out documents in SharePoint 2010


I have SharePoint 2010 environment. Many documents are checked out by other users.

I need to bulk check-in those documents. Can anyone suggest to me a reliable way for the same?

Thanks


Solution

  • You could try below PowerShell.

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
      
    #Variables
    $WebURL="http://domain/sites/emilytest"
    $LibraryURL="/Shared%20Documents" #Relative URL of a folder or library
     
    #Get Objects
    $Web = Get-SPWeb $WebURL
    $Folder = $web.GetFolder($LibraryURL)
     
    #Function to find all checked out files in a SharePoint library
    Function CheckIn-CheckedOutFiles($Folder)
    {
     
        $Folder.Files | Where { $_.CheckOutStatus -ne "None" }  | ForEach-Object {
        write-host ($_.Name,$_.URL,$_.CheckedOutBy)
     
        #To Check in
        $_.Checkin("Checked in by Administrator")
        }
     
       #Process all sub folders
       $Folder.SubFolders | ForEach-Object {
       CheckIn-CheckedOutFiles $_
       }
    }
     
    #Call the function to find checkedout files
    CheckIn-CheckedOutFiles $Folder