The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Hi @Manage BU
Thank you for reaching out to Microsoft Q&A.
After doing some research, I found this article might help.
How to Unlock a File in SharePoint Online: Fix Ghost Locks Fast
Note: This information is provided as a convenience to you. These sites are not controlled by Microsoft, and Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please ensure that you fully understand the risks before using any suggestions from the above link.
This article provides some basic methods such as wait until ghost lock is timed out (usually 10 minutes), discard check-out to advanced methods like using PnP PowerShell (If basic methods work then you don't need to use advanced steps).
If PnP is the last option, use this one. Set-PnPFileCheckedIn | PnP PowerShell
$fileUrl = "/sites/[sitename]/Shared Documents/MyLockedFile.docx"
Set-PnPFileCheckedIn -Url $fileUrl -CheckinType MajorCheckIn -Comment "Forcibly checked in by Admin"
Write-Host "File has been checked in."
Please refer to the article above for more details.
I hope this information helps.
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.