List All Checked Out Items Using PowerShell
If you’re in need of a report on checked out files across specific SharePoint site, and if you’re an administrator it is just a matter of time until someone will ask you for it, here is a simple but very useful PowerShell script that displays the report organized into few fields: site URL, who checked it out, since when was checked out, author’s name, file size and email address of the person who checked out the file. The result will be shown in the Management Shell Grid Viewer or you can output the report to a text file.
# enter your site URL $spWeb = Get-SPWeb "http://sp2013" function GetCheckedItems($spWeb) { Write-Host "Scanning Site: $($spWeb.Url)" foreach ($list in ($spWeb.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) { Write-Host "Scanning List: $($list.RootFolder.ServerRelativeUrl)" foreach ($item in $list.CheckedOutFiles) { if (!$item.Url.EndsWith(".aspx")) { continue } $writeTable = @{ "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)"); "Checked Out By"=$item.CheckedOutBy; "Author"=$item.File.CheckedOutByUser.Name; "Checked Out Since"=$item.CheckedOutDate.ToString(); "File Size (KB)"=$item.File.Length/1000; "Email"=$item.File.CheckedOutByUser.Email; } New-Object PSObject -Property $writeTable } foreach ($item in $list.Items) { if ($item.File.CheckOutStatus -ne "None") { if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue } $writeTable = @{ "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)"); "Checked Out By"=$item.File.CheckedOutByUser.LoginName; "Author"=$item.File.CheckedOutByUser.Name; "Checked Out Since"=$item.File.CheckedOutDate.ToString(); "File Size (KB)"=$item.File.Length/1000; "Email"=$item.File.CheckedOutByUser.Email; } New-Object PSObject -Property $writeTable } } } foreach($subWeb in $spWeb.Webs) { GetCheckedItems($subWeb) } $spWeb.Dispose() } GetCheckedItems($spWeb) | Out-GridView # alternative output file # GetCheckedItems($spWeb) | Out-File c:\CheckedOutItems.txt -width 300 |
First, open Notepad and Copy&Paste the above code. Save the file as a PowerShell file called “GetCheckedItems.ps1” on your SharePoint server under C: drive so it would be easier to access.
Open your SharePoint Management Shell (PowerShell) and type the following command and hit Enter.
./GetCheckedItems.ps1 |
And here is what you get.
To modify the output from the Grid View to a text file make the following changes to the previous script:
# GetCheckedItems($spWeb) | Out-GridView # alternative output file GetCheckedItems($spWeb) | Out-File c:\CheckedOutItems.txt -width 300 |
Good work, thanks for the script.
Thanks friend this is terrific!
Wonderful!!!!
Thanks so much! It was very helpful in resolving a problem with a user who had checked out a document and didn’t know they had. I wish there was way to disable the ability to check out files. There’s been quite a bit written about this; that you can’t disable check out on a document library with OOTB functionality.
Do you know of an adaptation of this that would work for all checked out files with no checked in version?
This will not work. $list.CheckedOutFiles will not return all document which are not checked out.
It will return only document which are uploaded to the document library but are not checked in.
Thanks, very useful.
thank you Max,your script helped me.