1

I found the following code which works like a charm as is... How do I modify it for a specific (known) list.

# 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
3

Here you go:

# enter your site URL
$spWeb = Get-SPWeb "http://sp2013"
$listName = "Your List Title"

function GetCheckedItems($spWeb)
{
    $list = $spWeb.Lists[$listName]
    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
        }
    }
}

GetCheckedItems($spWeb) | Out-GridView
$spWeb.Dispose()

# alternative output file
# GetCheckedItems($spWeb) | Out-File c:\CheckedOutItems.txt -width 300
  • Spot on, I'm still learning the ropes... ;) That is so simple... Thanks a Million. – RaveWolf Apr 18 '16 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.