Hi,

I received a recent requirement to create a report that provides the details of checked out items in an entire site collection. This report should also contain data for the person whom the document is checked out to. It should also provide the version and if no version exists it should mention the same.

So after playing with PowerShell for some time I prepared a script that works in exactly the same way.
If you want to extract this report to some .csv file then you need to provide this at the time of invoke itself.

 For example:-  .\ScriptName.ps1 >FileName.csv
During the execution it will ask for the site url which you need to provide. It works with both SharePoint 2007 and SharePoint 2010.

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
 
function CheckedOutItems() {
 
write-host "Please enter the site url"
$url = read-host
write ("SiteURL`t" + "FileName`t" +  "CheckedOutTo`t" + "ModifiedDate`t"+"Version")
$site = New-Object Microsoft.SharePoint.SPSite($url)
$webs = $site.AllWebs
foreach($web in $webs)
{
$listCollections = $web.Lists
foreach($list in $listCollections)
{
 
 
if ($list.BaseType.ToString() -eq "DocumentLibrary")
{
 $dList = [Microsoft.Sharepoint.SPDocumentLibrary]$list
 $items = $dList.Items
$files = $dList.CheckedOutFiles
foreach($file in $files)
{
 
$wuse = $file.DirName.Substring($web.ServerRelativeUrl.Length)
Write ($web.Url+ "`t" + $wuse+"`/" + $file.LeafName +  "`t" + $file.CheckedOutBy.Name + "`t" + $file.TimeLastModified.ToString()+"`t" + "No Checked In Version" )
}
 foreach($item in $items)
 {
 if ($item["Checked Out To"] -ne $null)
  {
$splitStrings = $item["Checked Out To"].ToString().Split('#')
 
  Write ($web.Url+ "`t" + $item.Url + "`t" + $splitStrings[1].ToString() + "`t" + $item["Modified"].ToString() +"`t" + $item["Version"].ToString())
 }
 }
 
  
}
 
 
 
}
$web.Dispose()
}
$site.Dispose()
}
 
 
CheckedOutItems

Other Languages

This article is also available in the following languages:

French (fr-FR) :