Share via


How to Manage files which have no checked in version in a SharePoint Document Library

Question

Monday, August 19, 2019 9:54 AM

Hi Team,

My project is related to migration. 

There are millions if records stored in my sharepoint content DBs. Many documents are checked out while uploaded into SharePoint but never checked in. Those documents are not having any version stored into SharePoint. Now i checked-in the documents forcefully which has at least one version. 

But i found there is a huge number of documents which has no version history. Though here i am not able to find a way to move ahead to migrate such documents.

But got trouble for some of the documents which were checked out but did not had at least a single version in SharePoint.  My power shell was also not able to read those documents.

Can anyone suggest me how to migrate such documents which are checked out but not had any versions in SharePoint.

Please let me know for any query.

/sanjay 

All replies (2)

Tuesday, August 20, 2019 1:12 AM ✅Answered

FYI

https://sharepoint.stackexchange.com/questions/192537/check-in-files-that-have-no-check-in-version-csom

Justin Liu Office Apps & Services MVP, MCSE
Senior Software Engineer
Please Vote and Mark as Answer if it helps you.


Tuesday, August 20, 2019 6:17 AM ✅Answered

Hi Joshi,

You can use the PowerShell script below to check in the file which have no checked in version in a library automatically:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
   
#Variables
$WebURL="http://demoaam.contoso2016.com/sites/dev"
$ListName="Documents"
  
#Get Objects
$Web = Get-SPWeb $WebURL
$List = $web.Lists.TryGetList($ListName)
  
If($List -ne $Null)
{
    #Get Checked out files with no checked in versions
    $CheckedOutFiles = $List.CheckedOutFiles
 
    Write-host "Total Number of Files with No Checkin version:"$CheckedOutFiles.count
 
    #Loop through each checked out File
    ForEach ($File in $CheckedOutFiles)
    {
        Write-Host -f Yellow "'$($File.LeafName)' at $($File.Url) is Checked out by: $($File.CheckedOutByName)"
         
        #Take ownership
        $File.TakeOverCheckOut()
        #Check in
        $List.GetItemById($File.ListItemId).File.Checkin("Checked in by Administrator")
        Write-host -f Green "Took Ownership and Checked in the File!"
    }
}
else
{
    Write-Host -f Yellow "List '$ListName' Does not Exist!"
}

Here I upload 4 pictures using Explorer view and I set Required Check Out to Yes, so this 4 files won't have checked in version in library:

Reference:

PowerShell to Manage Files Which Have No Checked in Version in SharePoint

Thanks

Best Regards

Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

SharePoint Server 2019 has been released, you can click

here to download it.
Click

here to learn new features. Visit the dedicated

forum to share, explore and talk to experts about SharePoint Server 2019.