List All Checked Out Items Using PowerShell - SharePoint 2010

http://www.topsharepoint.com/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
List All Checked Out Items Using PowerShell
And here is what you get.
List All Checked Out Items Using PowerShell
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

Comments

Popular posts from this blog

SharePoint 2016 and 2019 Ports

Clear fields based on drop-down values in PowerApps

Hide a SharePoint list field based on user group using JQuery Webservice in 2010