“Manage files which have no checked in version” list larger than list view threshold

Hey guys,

We ran into an interesting problem the other day after our company acquired another company. Basically the business wanted to consolidate a large amount of the acquired company’s documents into a SharePoint Library with similar documents. This part is fine and can easily be done using explorer view of the library and dragging and dropping the necessary folder structures.

The problem was that the library in question had the setting “Require Check Out” set to yes. This means that all the files that were dropped into the library using explorer view would need to be checked in as there would be no current version.

To make matters worse, the user who dumped all the files left the company, hence there is no checked in version and all the files remain invisible to everyone in the site.

Generally for a scenario like this you could use the option “Manage files which have no checked in version” from the library settings under Permissions and Management

Then from there you could take ownership of all the files, and check them in yourself.

But for our scenario the number of files dropped exceeded our list view threshold by a lot and we couldn’t even open the view “Manage files which have no checked in version“. However even if we could view all the files i.e. extending the threshold temporarily,  it would have been a real pain taking ownership of them all and checking them all in.

PowerShell Solution.

I developed a short little set of PowerShell Functions that can take ownership of the files, then recursively check in all files that are being checked out by the system account.

#Add SharePoint Snapin if not using SharePoint's PowerShell Console
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
Add-PsSnapin Microsoft.SharePoint.PowerShell
#First function takes ownerhip of all unmanaged files with no version
function Take-Ownership{
$site = Get-SPWeb -Identity $spSite
$list = $site.Lists[$spList]

$list.CheckedOutFiles | ForEach-Object{
$_.LeafName+ " had it's ownership taken from: "+$_.CheckedOutBy.DisplayName+"`n"
#This Function takes a folder object and recursively checks in
#all files which are checked out by the System Account
function checkin-AllFiles{
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]

$currFolder.Files | ForEach-Object {
if ($_.CheckedOutByUser.UserLogin -eq "SHAREPOINT\system"){
$_.CheckIn("File checked in by administrator")
$_.Name+" has been checked in`n"
$currFolder.SubFolders| ForEach-Object{
checkin-AllFiles -currFolder $_
#This function basically combines the previous 2 for primary use
function Checkin-AllUnmanagedFiles{
$spSite = Get-SPWeb -identity $site
$spFolder = $spSite.Folders[$library]

"Taking ownership of the following Files`n"
Take-Ownership -spSite $site -spList $library

"Checking in the following files`n"
checkin-AllFiles -currFolder $spFolder

We can then run the script and use the Checkin-AllUnmanagedFiles function.

PS> Checkin-AllUnmanagedFiles -site "http://yoursite/" -library "Library Name"

For example I have a “Shared Documents” library which requires files be checked out for editing. I then dropped a few files into it’s explorer view

We can now see that these files show up in the library but are all checked out to myself hence no other user can see the file as there is no previous version yet.

Now if we run my script from the command shell:
(Note: I saved my script in a ps1 file called CheckinFiles.PS1)

PS> . .\CheckinFiles.PS1
PS> Checkin-AllUnmanagedFiles -site "http://torapd149:3434/subsite/" -library "Shared Documents" > .\checkin.txt

We can see all the files have now been checked in and modified by the System Account. Also I sent the output to a logfile called checkin.txt which tells which files were taking ownership of and which files were checked in.

Hopefully you will find this as useful as I have.


14 thoughts on ““Manage files which have no checked in version” list larger than list view threshold

  1. I just had the exact issue with a massive file upload (uploaded using the Windows Explorer view), and all of the files were invisible to the entire organization (over 2,000 files).

    Your solution fixed this issue in less than a minute!

    Thank you, thank you, thank you…


  2. Pingback: When you need to add new documents with explorer in SharePoint library | Yuseon Hwang's blog

    • I suppose you could, but it would be risky as there are a lot of system folders used by SharePoint, that could cause this to be a real strain on the server going throuh many loops.

      you would basically need another function that recursively went through all spWeb objects. It would have a similar form to the checkin-AllFiles function except you would use the paramater [Microsoft.SharePoint.SPWeb] instead and loop through all spWeb.webs objects. From within this new function you could call the Checkin-AllUnmanagedFiles function which you would also need to modify to not take a $library parameter but instead loop through all Folders calling the checkin-AllFiles function. a modification like such:
      $spSite.Folders | ForEach-Object{
      “Taking ownership of the following Files”
      Take-Ownership -spSite $site -spList $_.Name
      “Checking in the following files”
      checkin-AllFiles -currFolder $_

      Unfortunately the computer that had my dev environment on is toast right now so I haven’t been able to test this out myself. Also a word of warning when looping through SPWeb objects remember to dispose of them afterwards as they can remain in use by IIS almost indefinitely consuming resources

      Let me know how it goes

    • Hi Claudia,

      This script handles files in which no previous version has been checked in. So technically it will modify the files in the sense that it says the system account was the person to last modify and not the initial creator. But it writes to the check-in comments who the file was initially checked out to. A manual alternative would be to modify the Take-Ownership method in my script to print out a list of files and who they are checked out too, then you could do a mail merge and have everyone check-in their own files.


    • Great Question, unfortunately I haven’t really explored this scenario with SharePoint Online and don’t know if it is possible or not as it is more of a back-end approach. If you are facing this issue with SharePoint Online, I’d recommend contacting support directly.

  3. Hi,
    When I run the script it is throwing me an error ” the term ‘Checkin-AllUnmanagedFiles ‘ is not recognized as the name of a cmdlet, function, script file, or operable program ‘

    Any idea/suggestion ?


    • 2 things come to mind with this.
      The first would be to check the script and make sure any quotations “” got copied properly from the browser. Sometimes the browsers uses different ascii characters then what Powershell uses so you may need to replace the “” symbols.
      The second is to make sure your using “Dot Sourcing” when running the script for the functions become available. you can do this by saving the script file called “CheckinFiles.PS1” then at the powershell comand run:
      . .\CheckinFiles.PS1

      • I somehow managed to run the script but now there are two errors coming up
        1. You cannot call a method on a null-valued expression

        2. Cannot bind argument to parameter ‘currFolder’ because it is null.

        Can you help me on this ?

      • This sounds like you didn’t specify the correct name for the Document Library in question when you ran the script. when running the script be sure to include the flag -Library “Library Name”

  4. Great Post Brent!

    It has been close to 5 years since you posted this and I find this to be one of the best/clearest guide out there on resolving this cumbersome issue.

    One challenge – we are on SharePoint 2013 (Online). Are the modules you have used still applicable? Otherwise, do you have a link to resource where I might be able to piece together the relevant modules to make this work for SharePoint 2013 (Online)?

    Thank you and looking forward to your reply.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s