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.
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
Comments
Post a Comment