0

I have a site that was just migrated to SPO, and had "require checkout" turned on by default on the Documents library. Users have since bulk-uploaded a few hundred docs without checking them in. Luckily I have a PnP script for just such an occasion which simply loops through every item and checks it in if needed. The problem is that the folder structure in this library is deeeeeep, and it seems that my script doesn't plumb the depths like it should. Documents that are buried deep in the structure don't get checked in for some reason. I'm using paging to limit results so that I don't run into the LVT, but I'm not sure how else to make the script check every doc. Anyone know how to accomplish that, or at least why it's failing? Is there another method I should try?

Here's what I'm working with:

$ListItems = Get-PnPListItem -List $ListName -PageSize 500 | Where {$_["FileLeafRef"] -like "*.*"}
ForEach ($Item in $ListItems)
{
    $File = Get-PnPProperty -ClientObject $Item -Property File
    If($File.Level -eq "Checkout")
    {
        Set-PnPFileCheckedIn -Url $File.ServerRelativeUrl -CheckinType MajorCheckIn -Comment "Fixing checkout"
    }
}

Edit: The deep folder structure may be just a coincidence, I found one document that got skipped but is in a much shallower folder.

0

As a workaround, you could use SharePoint Online PowerShell csom to achieve it.

Here are two blogs for your reference:

https://gallery.technet.microsoft.com/office/Find-all-checked-out-files-56fd562d https://social.technet.microsoft.com/wiki/contents/articles/34215.sharepoint-online-get-all-checked-out-files-using-powershell.aspx

1
  • Unfortunately CSOM isn't allowed in my organization, but I appreciate the suggestion – thanby Oct 23 '20 at 16:25

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.