Find all checked out files in the farm

Posted on Updated on

Here’s a better script I found to get all checked out files on the farm. You can just add the check-in code from my previous blog if needed.

function Get-CheckedOutFiles() {

    foreach ($web in (Get-SPSite -Limit All | Get-SPWeb -Limit All)) {

        Write-Host “Processing Web: $($web.Url)…”

        foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {

            Write-Host “`tProcessing List: $($list.RootFolder.ServerRelativeUrl)…”

            foreach ($item in $list.CheckedOutFiles) {

                if (!$item.Url.EndsWith(“.aspx”)) { continue }

                $hash = @{

                    “URL”=$web.Site.MakeFullUrl(“$($web.ServerRelativeUrl.TrimEnd(‘/’))/$($item.Url)”);

                    “CheckedOutBy”=$item.CheckedOutBy;

                    “CheckedOutByEmail”=$item.CheckedOutByEmail

                }

                New-Object PSObject -Property $hash

            }

            foreach ($item in $list.Items) {

                if ($item.File.CheckOutStatus -ne “None”) {

                    if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue }

                    $hash = @{

                        “URL”=$web.Site.MakeFullUrl(“$($web.ServerRelativeUrl.TrimEnd(‘/’))/$($item.Url)”);

                        “CheckedOutBy”=$item.File.CheckedOutByUser;

                        “CheckedOutByEmail”=$item.File.CheckedOutByUser.Email

                    }

                    New-Object PSObject -Property $hash

                }

            }

        }

        $web.Dispose()

    }

}

Get-CheckedOutFiles | Out-GridView

From here –> http://blog.falchionconsulting.com/index.php/2011/06/getting-and-taking-ownership-of-checked-out-files-using-windows-powershell/

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s