Wednesday 6 November 2013

Reterive a list of checkout file in sharepoint 2010 site collection using powershell

Share it Please
Script:-

$webAppURL = "Enter your Web application Url"

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
            }
        }
    }
}

ReportCheckedOutItems

No comments:

Post a Comment

Followers

Follow The Author