SharePoint 2010: PowerShell Script to List the Documents Checked Out with Version Details in a Site Collection

SharePoint 2010: PowerShell Script to List the Documents Checked Out with Version Details in a Site Collection

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 versions.

[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) :

Leave a Comment
  • Please add 1 and 1 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Benoit Jester edited Revision 5. Comment: Add french link

  • Richard Mueller edited Revision 3. Comment: Modified title casing, Removed tag "SPS2010"

  • Richard Mueller edited Revision 1. Comment: Modified title casing, minor edits, added  tag

Page 1 of 1 (3 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Hi Rashul

    Thanks for the script, its excellent! im new to Powershell so sorry if its an easy question..

    If you wanted to include the email address of the user who has the item checked out, how would you adding this to the script?

    Thanks

    James

  • Hi JamesVose,

    You just need to modify this line Write ($web.Url+ "`t" + $wuse+"`/" + $file.LeafName +  "`t" + $file.CheckedOutBy.Name + "`t" + $file.TimeLastModified.ToString()+"`t" + "No Checked In Version" ).

    Here you need to add the EMail property pf SPUser class as $file.CheckedOutBy.Email.

    I hope this will help you out.

    Thanks,

    Rahul Rashu

  • Richard Mueller edited Revision 1. Comment: Modified title casing, minor edits, added  tag

  • Richard Mueller edited Revision 3. Comment: Modified title casing, Removed tag "SPS2010"

  • Benoit Jester edited Revision 4. Comment: Add french link

  • Benoit Jester edited Revision 5. Comment: Add french link

Page 1 of 1 (6 items)