EricHarlan

What is checked out and how big is it?

I had a customer requirement today that needed to see all the checked out files in a farm and their file sizes as well as who had them checked out.  Lucky for me I was trading emails with Garly LaPointe at the moment. He tossed me a link to one of his blog posts where he essentially had to do the same thing.

I then made some minor modifications, first to give me all the checked out files in a sepecific site collection as well as give me the file size of the checked out file. Obviously i take no credit for the overall script that was Gary’s doing but I figured it worth posting so at aleast if anyone else needed the same script they could use it. This was tested in SharePoint 2010, I’m assuming it would work 100% in 2013.

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

The red URL in the script is where you would put your site collection URL. The output of running this script would be a text file on the C drive (last line of the script) called CheckedOut.txt which would give you the person, file, size.

function Get-CheckedOutFiles() {

$site=Get-SPSite http://spapp02:1616

foreach ($web in $site.AllWebs) {

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) {

$hash = @{

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

“CheckedOutBy”=$item.CheckedOutBy;

“CheckedOutByEmail”=$item.CheckedOutByEmail;

“Size”=$item.File.Length/1KB

}

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;

“Size”=$item.File.Length/1KB

}

New-Object PSObject -Property $hash

}

}

}

$web.Dispose()

}

}

Get-CheckedOutFiles | Out-File c:\CheckedOut.txt -width 220

 

Leave a Reply

Your email address will not be published.

No seriously, are you human? *