I have a document lib that has been stale for a few years. I am trying to clean it up, but there are 1000+ document that are Checked Out to another user. I am a super admin, so I can go in and get take ownership / check these documents in individually. But that would take HOURS and there may be many more libraries that I need to sort through.

I see there is the Set-PnPFileCheckedIn command for PowerShell, which is good, but what I don't see is a command to take ownership of checked out files. Or a settings on the following commands that would allow me to loop through checked out items:




Get-PnPFiel -asListItem

As of now the commands I listed above only return checkedin items, or items that are checked out under your user sessioned account.

Is it that I need to run a command as the user that has the documents checked out?

I know the ListItem fields have a field like CheckedOutTo but that does not help when you cannot get a list of said checkedout items to update who the document is currently checked out too.

Looking for a PnP command solution to this. If at all possible. I see some solutions using the older SPO commands, and if that is the only way than so be it, but I am tring to stick within the realm of PnP commands.

Thanks all in advance!


2 Answers 2


I was able to figure this out by using the $context.Load($thing); $context.ExecuteQuery()

# Setup the site context
[Microsoft.SharePoint.Client.Web] $Connection = Get-PnPWeb
$context = $Connection.Context
[Microsoft.SharePoint.Client.List] $list = Get-PnPList $listName

# Load the list

# Load the checked out files
$chkdOutFiles = $list.GetCheckedOutFiles()

foreach ($file in $chkdOutFiles) {
    # Do Actions...

Some thing I was noticing is that the Get-PnPxxx functions don't return all data and that in some instances you need to load the object like above. I thought this processes was more required by the older Get-SPOxxx functions, but I guess is also needed for PnP.

@Martin Muldoon got me on the right track to figuring this out. So thank you sir!


To loop through the check out items, couldn't you simply:

$lists = Get-PnPList -Web $web
foreach($list in $lists)
     $checkedOutItems = $list.GetCheckedOutFiles()
     foreach($file in $checkedOutItems)
           #take action

UPDATE ------------------------

I was not iterating through the collection correctly. Try this:

 foreach($file in $list.checkedOutItems)
           #take action
  • 1
    Ah! I saw that on some other threads but couldn't determine if the GetCheckedOutFiles() function was an accessible function/property for that Get-PnPList signature. @Martin, I will give this a try and get back to accepting your answer today. Thanks!
    – Daniel W
    Aug 30, 2019 at 12:03
  • the GetChceckedOutFiles() method is returning a CheckedOutFileCollection object, and the properties are accessible: Count = 2000+. However, the object does not see to be iterable. In the loop conditional line, it gives me The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested. Looking over the class definition, but not sure that is helping me.
    – Daniel W
    Sep 3, 2019 at 14:56
  • Check out my answer. Your before UPDATE --- was closer to correct.
    – Daniel W
    Sep 3, 2019 at 17:04

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.