Get Checkout Files List in Microsoft SharePoint Server 2010

Introduction

This script could be used to get a list of checkout files from a site collection in Microsoft SharePoint Server 2010. You can also get a list of files which checkout by specific user.

Scenarios

In a real world, IT administrators often need to get a checkout files list in Microsoft SharePoint Server 2010, especially after the resignation of an employee. It will be a heavy task if they do it manually. It’s better to use a script to generate a checkout files list automatically.

Script

This script contains one advanced function, Get-OSCSPCheckoutFileList. You can use this script in following ways:

Method 1:

1. Download the script and copy it to a Microsoft SharePoint 2010 server.

2. Open the script file with Notepad or any other script editors.

3. Scroll down to the end of the script file, and then add the example command which you want to run.

4. Save the file then run the script in SharePoint 2010 Management Shell.

Method 2:

1. Rename scriptname.ps1 to scriptname.psm1 (PowerShell Module file)

2. Run Import-Module cmdlet to import this module file.
Import-Module filepath\scriptname.psm1

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

PowerShell
Edit|Remove
#Get specified list if user provides a list name. 
#Otherwise, iterate each list. 
if ($ListName -ne "*" ) { 
    $spList = $spWeb.Lists.TryGetList($ListName) 
    if ($spList -ne $null) { 
        if ($spList.BaseType -eq "DocumentLibrary") { 
            $spLists +$spList 
        } else { 
            $errorMsg = $Messages.NonDocList 
            $errorMsg = $errorMsg -$ListName 
            $customError = New-OSCPSCustomErrorRecord ` 
            -ExceptionString $errorMsg ` 
            -ErrorCategory NotSpecified -ErrorID 1 -TargetObject $pscmdlet 
            $pscmdlet.WriteError($customError)                     
        } 
    } else { 
        $warningMsg = $Messages.CannotFindSpecifiedList 
        $warningMsg = $warningMsg -$ListName,$($spWeb.Title) 
        $pscmdlet.WriteWarning($warningMsg) 
    } 
} else { 
    foreach ($spList in $spWeb.Lists) { 
        if ($spList.BaseType -eq "DocumentLibrary") { 
            $spList = $spWeb.Lists.TryGetList($spList.Title) 
            $spLists +$spList 
        } 
    } 
}

Examples

Example 01: Displays help about Get-OSCSPCheckoutFileList
Command: Get-Help Get-OSCSPCheckoutFileList -Full 
Screenshot:

Example 02: Get checkout file list, including all users.
Command
Get-OSCSPCheckoutFileList -SiteCollectionURL "http://server_name/sites/*" -ListName "Shared Documents" -Verbose
Screenshot:

Example 03: Get checkout file list, for a specific user.
Command
Get-OSCSPCheckoutFileList -SiteCollectionURL "http://server_name/sites/*" -ListName "Shared Documents" -UserLogin "domain\user" -Verbose
Screenshot:

Example 04: Get checkout file list and export the report to a csv file.
Command
Get-OSCSPCheckoutFileList -SiteCollectionURL "http://server_name/sites/*" -ListName "Shared Documents" -Verbose | Export-Csv -Path c:\Scripts\report.csv -NoTypeInformation
Screenshot:

Example 05: Find checkout files from all lists which base type is DocumentLibrary.
Command
Get-OSCSPCheckoutFileList -SiteCollectionURL "http://server_name/sites/*" -ListName "*" -Verbose
Screenshot:

Additional Resources

Technical Resources:

Windows PowerShell Advanced Function

Microsoft.SharePoint.SPWeb Class

Microsoft.SharePoint.SPList Class

Microsoft.SharePoint.SPFile Class

Forum Threads:

Get the checkout file based on users Name