locked
find out the document libraries in the site collection which are not having checked out files and which are having checked out files. RRS feed

  • Question

  • Hi Everyone,

    we need to find out the document libraries which document libraries are not having checked out files and which document libraries are having checked out files in the site collection.

    can any one guide me.


    • Edited by PVR1988 Tuesday, November 8, 2016 12:21 PM
    Tuesday, November 8, 2016 12:09 PM

All replies

  • Hi,

    You can use this script to list out all the checked out documents in a site collection. You can also improve upon the script to output libraries that do not have any checked out documents.

    https://myspworld.wordpress.com/2012/10/16/retrieve-a-list-of-all-items-checked-out-in-a-site-using-powershell/

    $webAppURL = "http://yourwebapplication.com"
     
    function ReportCheckedOutItems() {
        $webapp = Get-SPWebApplication $webAppURL
     
        foreach ($site in $webapp.Sites) 
        {
            write-host "Site Collection: $($site.Url)"
            $allwebs = $site.allwebs
            foreach($web in $allwebs)
            {
                $count = 0
                write-host "--Site: $($web.Url)"
                foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
                    Write-Host "-----List: $($list.RootFolder.ServerRelativeUrl)..."
                    foreach ($item in $list.CheckedOutFiles) 
                    {
                        if (!$item.Url.EndsWith(".aspx")) 
                        { 
                            continue
                        }
                        write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
                        $count++
                    }
                    foreach ($item in $list.Items) 
                    {
                        if ($item.File.CheckOutStatus -ne "None") 
                        {
                            if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) 
                            { 
                                continue
                            }
                            write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
                            $count++
                        }
                    }
                }
                if ($count -gt 0)
                {
                    write-host "Found $count checked out files for site $web" -ForeGroundColor Red
                }
            }
        }
    }
     

    Thanks,

    Priyan


    Please Up Vote and Mark this as Answer if it helps.

    Tuesday, November 8, 2016 12:29 PM