FluentPro Help Center

What do you need help with?

    Sorry, we didn't find any relevant articles for you.

    Send us your queries using the form below and we will get back to you with a solution.


    How to check in Library Documents using PowerShell script

    Symptoms

    Documents count for a Library on Site Contents page is more than the number of visible documents in the Library and than downloaded into FluentBooks workspace. 

    Cause

    Files which have no checked in version are not visible in the Library and are not available for download via API. 

    Solution

    Files which have no checked in version need to be checked in before downloading them using FluentBooks.

    FluentPro developed a PowerShell script that allows to bulk-check in files.

    Please note: This script will check in all checked out documents in the specified Libraries, not only those that have no checked in version.

    Please note: This script needs to be executed on the SharePoint Farm server in SharePoint PowerShell Console.

    PowerShell Script

    $pwaUrl = 'PWA URL'
    $docLibs = @('Lib1', 'Lib2')
    $site = Get-SPSite $pwaUrl
    foreach($web in $site.AllWebs)
    {
     Write-Host "Process site: $($web.Url)"
     $libraries = $web.GetListsOfType(1)
     foreach($lib in $libraries)
     {
     if($docLibs -contains $lib.Title -and $lib.ForceCheckout -eq $true)
     {
     Write-Host "Process document library: $($lib.Title)"
     foreach($file in $lib.CheckedOutFiles)
     {
     Write-Host "Take over checkout: $($file.Url)"
     $file.TakeOverCheckOut()
     }
     foreach($item in $lib.Items)
     {
     if($item.FileSystemObjectType -eq 'File' -and $item.File.CheckOutStatus -ne "None")
     {
     Write-Host "Check in file: $($item.File.Url)"
     $item.File.CheckIn('')
     }
     }
     }
     }
    }

    Cope the script text into a text file, specify your PWA URL and Libraries names in the script text, save the file as a PowerShell script (with *.ps1 extension):

    $pwaUrl = 'PWA URL'
    $docLibs = @('Lib1', 'Lib2') 

    The script will check in Documents in each specified Library in the root PWA site, as well as in all PWA subsites. 

    If you have questions about the script, please contact FluentPro Support Team at support@fluentpro.com.

    Was this article helpful?

    Table of contents

      Still can't find what you're looking for?

      Contact Support
      Back To Top