Export all checked-out files from SharePoint site using PowerShell

Straightforward PowerShell script designed to export all the checkedout files from all libraries from the SharePoint Site, utilizing PnP PowerShell.

Here’s a simple PowerShell script to export the list of all checkedout files from all libraries in a SharePoint Site by using PnP PowerShell.

Write-Host "Execution Started"
$siteurl = "https://.sharepoint.com/sites/"
$ctx = Get-PnPConnection
If($ctx.Url.ToLower() -ne $siteurl.ToLower()){
    Connect-PnPOnline $siteurl -Interactive
    Connect-PnPOnline $siteurl -Interactive
Write-Host "Connected to Site"
#Get All libraries from the site
$alllibraries = Get-PnPList | Where-Object {$_.BaseTemplate -eq 101}
#Get checkedout files from the library
$results = @()
foreach($library in $alllibraries){
    Write-Host $library.Title
    $checkedoutfiles = Get-PnPFileInFolder -Identity $_.Title -Recurse | Where-Object {$_.CheckOutType -eq [int64]0} 
    foreach($file in $checkedoutfiles){
        $user = Get-PnPUser -Identity $file.CheckedOutByUser
        $results += [pscustomobject][ordered]@{
            Name    = $file.Name
            Library = $library.Title 
            FilePath  = $file.ServerRelativeUrl
            CheckedOutByUser = $user.Email
# Export concatenates results in a checkedoutfiles.csv in running path
$results | Export-Csv -Path "checkedoutfiles.csv" -NoTypeInformation
Write-Host "Export Completed."
Write-Host "Execution completed."

The above script executes and iterates to all libraries and also on all subfolders and fetch the details and exported to the csv file in current running path.

For more information, Installing PnP PowerShell

Shantha Kumar
Shantha Kumar
Articles: 295

Leave a Reply

Your email address will not be published. Required fields are marked *