Powershell tip – find all checked out files

I needed to quickly find all files in a particular web that were checked out. I immediately went to Powershell, and after hacking about for a few minutes did what I should have done first – Google’d it. Doing this revealed that Gary had already done the bulk of what I needed to do. However, I made a couple of changes, namely that I only wanted it to traverse a specific web, but I needed it to traverse any subwebs in that web and lists.

function GetCheckedOutFiles($web)
Write-Host "Processing Web: $($web.Url)..."
        foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
            Write-Host "`tProcessing List: $($list.RootFolder.ServerRelativeUrl)..."
            foreach ($item in $list.CheckedOutFiles) {
                if (!$item.Url.EndsWith(".aspx")) { continue }
                $hash = @{
                New-Object PSObject -Property $hash
            foreach ($item in $list.Items) {
                if ($item.File.CheckOutStatus -ne "None") {
                    if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue }
                    $hash = @{
                    New-Object PSObject -Property $hash
foreach($subWeb in $web.Webs)
$web = get-spweb $args[0]

Save it as GetCheckedOutFiles.ps1 and you would then call it with

./GetCheckedOutFiles http://urltoweb | Format-Table url | out-file output.txt -width 500

(or do as Gary does and save it as cmdlet for easy reuse.)


  1. Hi Matt,

    Can i use this script to get all checked out files in document library in sharepoint online 2013 office 365?

    Many thanks in advance for your reply


  2. Hi Terry. Re: 2) it will already do this, just call it like this:
    ./GetCheckedOutFiles http://urltoweb | Format-Table url,CheckedOutBy | out-file output.txt -width 500

    RE: 1) Powershell has some SMTP capabilities available using the stuff in the Net.Mail assemblies. So you could actually just update this script and pipe the output in to the email message. Have a look at this for inspiration: http://gallery.technet.microsoft.com/scriptcenter/Simple-Powershell-function-8e826d7c

    If i get a moment I’ll repost the script in its entirety.

  3. Thanks for that. Apologies for getting back so late. This is great.

    Now whilst this was a very useful exercise and I hava managed to get people to close down checked out files, I need to do this on a regular basis.

    So I am thinking.
    1. I should combine this with a powershell email script to email me the list of checked out files every time it is scheduled to run via task scheduler.
    2. It would be great if there was a way to add a column to also show who this file is checked out to.

  4. Sorry to be a pain, How do I increase the width of the output table. I have tried googling but getting a bit lost.

  5. Thank you so much for providing this script. just what I need

    I have run your script above. Seems like it cuts off the end of the URL. I have saved the output to a txt file.

    Am I doing something wrong?

2 Trackbacks / Pingbacks

  1. Retrieve a List of All Items Checked Out in a Site using Powershell « myspworld
  2. What is the difference? (Checked out files) | Question and Answer

Leave a Reply

Your email address will not be published.