We want to force check-in all the documents at "site collection level" i.e from all its sub-sites and all document library. Would need help on a powershell script which can do the same.

BR/ Somesh

1 Answer 1


The following PowerShell Script will check in all checked out files on the specified site collection. It iterates each web in the site collection, gets all lists of type DocumentLibrary (not hidden), gets all checked out files, and checks each one in.

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue

$siteUrl = "http://yoursharepointsite"
$webs = (Get-SPSite -Identity $siteUrl).AllWebs
ForEach ($web in $webs) {
    $libs = $web.GetListsOfType(1)
    ForEach ($lib in $libs | ? { $_.Hidden -eq $false }) {
        $files = $lib.CheckedOutFiles
        ForEach ($file in $files) {
            $f = $web.GetFile("/" + $file.Url)
            $f.CheckIn("Checked in by System")
            Write-Host -ForegroundColor Green "File: $($file.Url) checked in!"

Hope this helps!

  • 1
    This script is the real McKoy!!! Works like a charm...
    – L. James
    Commented Jan 8, 2019 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.