Checkinn script for SharePoint documents in the library

sns 9,226 Reputation points
2023-01-23T16:49:26.9133333+00:00

Checkinn scrript for SharePoint documents in the librrary.

is there any sccript to check in ( unlock ) the locked files in the libbrary, all are from one library only. And if we ran that script how long it may take?

Thank you in Advance.

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,218 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,610 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Xuyan Ding - MSFT 7,561 Reputation points
    2023-01-24T09:31:37.54+00:00

    Hi @sns,

    • You can check in by selecting all documents. User's image User's image If you need PowerShell, you can take a look at this article: Check In All Documents in a SharePoint Library using PowerShell. Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link. 
    • If the user cannot edit the document after checking in, then it should not be that someone has performed a batch checkout operation on the documents of this library. The reason for locking the document may be that a service was not called when the document was closed. At this point, you may need to fix it by disabling the cache removal option in word or at worst try to install the latest CU.
    • User's image
    • ==================Update
       $WebURL="http://sp2016/sites/sp" 
       $LibraryName="Documents" 
       $Web = Get-SPWeb $WebURL 
       $DocLib = $Web.Lists.TryGetList($LibraryName) 
       $CheckedOutFiles = $DocLib.Items | Where-Object { $_.File.CheckOutStatus -ne "None"} 
       ForEach($item in $CheckedOutFiles) { 
       $DocLib.GetItemById($item.Id).file.CheckIn("Checked in by xx\administrator") }
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.