I am not a expert in sharepoint but tried something that worked for me. So just giving a thought.
- Make sure the person should have either full control to the site or is a sitecollection administrator.
- Please note that this was the migration technique that we used to migrate the documents which have no checked in version because metalogix was not able to migrate those documents.
You can first write powershell script that opens the ie browser silently and manupulate the DOM of the page (Managed file which have no checked in version).
$ie = new-object -com internetexplorer.application
#below code to select the elements to take control of the document (left hand side checkbox)
$jsCommand = @"
$document = $ie.document
$window = $document.parentWindow
#this is the code to click the "Take The Ownership" link
$link = $ie.Document.getElementById('ctl00_PlaceHolderMain_Toolbar_RptControls_ButtonRestoreItems_LinkText')
#do the dispose of the object
Second Step (Validation):
After you ran this in powershell ISE, then please execute this below code to see if now you can get the manage files which has no checked in item count. If then you can retrive the item then the account can do checkin of the document without any issue.
Add-Type –Path $currentDir"\ClientDLL\Microsoft.SharePoint.Client.dll"
Add-Type –Path $currentDir"\ClientDLL\Microsoft.SharePoint.Client.Runtime.dll"
$urlSite="sharepoint web url"
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($urlSite)
#$clientContext.Credentials = New-Object System.Net.NetworkCredential("username with domain", "password")
$list = $clientContext.Web.Lists.GetByTitle("document library name");
$caml = "<View Scope='RecursiveAll'><Query><Where><IsNotNull><FieldRef Name='CheckoutUser' /></IsNotNull></Where></Query></View>"
$cq= New-Object Microsoft.SharePoint.Client.CamlQuery
$items = $list.GetItems($cq)
If you are using in ServerObject Model I can say that you can look for TakeOverCheckout method as pointed here but it is valid only for on-premise environment. Literally I have never tried it but maybe worth mentioning. Please look at the documentation below:
Best of luck!!