I have a problem with thousands of files not being checked in after upload to one of our site collections. I can't open the list of files with no version through the UI because of the exceeded treshold.

I have written a PowerShell script to check for CheckedOut files and check them in, however it looks like those files without checked in version are not visible from my admin account (I am the site collection administrator) even through PowerShell. I am using Get-PnPListItem cmdlet.

I have all the accesses including admin center etc, but I'm unable to find and check in those files. There's no knowledge/access to the account that uploaded the files.

Is there any way to get them?

Thanks a lot

  • did you get anywhere with this one? I'm facing the same issue with over 1500 items
    – HBFS2018
    Commented Oct 23, 2018 at 3:56

2 Answers 2


You might need to take ownership of the file before you can checkin. Please try below powershell script.

$web = Get-SPWeb "http://url_of-your-site"
$list = $web.Lists["NameOfDocumentLibrary"]

$files = $list.CheckedOutFiles

foreach($cf in $files)
    $file.TakeOverCheckOut() #Take Ownership

    $itemId = $file.ListItemId
    $item = $list.GetItemById($itemId)
    $newFile = $item.File
    $newFile.CheckIn("Checkin Comments")

    # If the library has minor major version enabled
    # $newFile.Publish("")

Update: The above script works for SharePoint 2013. The below code performs the same using CSOM and works for SharePoint Online.

$currentDir = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$packagesPath = "Path to CSOM Nuget Package/library"

#Add references to SharePoint client assemblies and authenticate to Office 365 site – required for CSOM
Add-Type -Path ($packagesPath + "/Microsoft.SharePoint.Client.dll")
Add-Type -Path ($packagesPath + "/Microsoft.SharePoint.Client.Runtime.dll")

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

$userName = Read-Host -Prompt 'Enter your email address'
$pwd = Read-Host -Prompt 'Enter your password' -AsSecureString

$context = New-Object Microsoft.SharePoint.Client.ClientContext("URL of the site")

$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $pwd)

$web = $context.Web;
$list = $web.Lists.GetByTitle("Name of Documnet Library")
$files = $list.GetCheckedOutFiles()
$user = $web.CurrentUser;


foreach($file in $files)
    if($file.CheckedOutById -ne $user.Id){

        $fileUrl = [string]::Concat($list.ParentWebUrl, $file.ServerRelativePath.DecodedUrl.Replace($list.ParentWebUrl, ""))
        $newFile = $web.GetFileByServerRelativeUrl($fileUrl)
        $newFile.Checkin("", 1)
  • Hi, I am working with SharePoint Online, so the above won't work. However, already when returning the Checked Out Files from the list, these files that have no checked in version will not be found, as from my understanding they are visible only to the uploader before they are checked in by default...
    – xmihu
    Commented Sep 12, 2018 at 13:15
  • My bad, did not see that you are using SPO. A similar code in CSOM would work with SPO. When you check SPList.Items the files with no checked in versions will not be found. However SPList.CheckedOutFiles will have list of files that have never been checked in. See msdn.microsoft.com/en-us/library/…
    – sssreddy
    Commented Sep 12, 2018 at 14:17
  • See my updated answer.
    – sssreddy
    Commented Sep 12, 2018 at 18:32
  • There is no method called "GetCheckedOutFiles" in CSOM. Did it work for any of you guys?
    – suryakiran
    Commented Mar 16, 2020 at 21:09
  • This method should be available in CSOM, make sure you have updated version. See docs.microsoft.com/en-us/dotnet/api/…
    – sssreddy
    Commented Mar 17, 2020 at 2:20

you might need to create a view on the document library in order to see fewer files in the view, otherwise SP will likely display no files. Go in via the Doc Library Settings>Create View>apply a filter e.g. show only files created today or in the last month. You should be able to see a filtered selection of files.

You might also want to try copying files to a new document library, in order to get under the 5,000 item limit. You'll find administering the document library easier once you are under the limit. Try going via the Site Settings>Content and Structure to copy or move the files to a new doc library. (n.b. there is a difference between copy or move - I remember something about one method preserving the version history of the files, I don't know if you need to keep version history or not?).

Another thing you can do is access the Manage Files Which Have No Checked in Version in the Document Library Settings menu - I know you've mentioned this in the title of your question, but nothing in the body of your question - it could be that this is unavailable to you due to there being too many files saved in a single Document Library. But once you've copied files elsewhere and are under 5,000, this should become available to you.

  • Thanks, but views in the document library won't help. I can see files in the document library as they are in multiple different folders - it won't ever show files that have no checked in version though, that's why I tried PowerShell, unfortunately with no success. 'Manage files which have no checked in version' won't open up as the list is over treshold. I can't move those files as they are not visible through UI (again, there is no checked in version).
    – xmihu
    Commented Sep 12, 2018 at 11:54
  • I think you should try splitting the files in to groups of less than 5,000 items, as I described above
    – Tally
    Commented Sep 12, 2018 at 13:06
  • This is not the issue as I can reproduce something similar on a very small library. I upload a file from a 'normal' account, the file is checked-out and has no checked in version, then I can't find it with PowerShell even with admin account with Full Control, even though it is visible with the account it was uploaded from.
    – xmihu
    Commented Sep 12, 2018 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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