Excel File Locked for Editing by a Deleted User: Root Cause and Fix
🔍 WiseChecker

Excel File Locked for Editing by a Deleted User: Root Cause and Fix

You open an Excel file stored on SharePoint or OneDrive and see a message that the file is locked for editing by a user who has been deleted from Microsoft 365. You cannot edit the file, and the lock does not clear after the user is removed. This problem occurs because SharePoint retains the file check-out lock even after the user account is deleted. This article explains why the lock persists and provides the exact steps to release it.

Key Takeaways: Unlocking an Excel File After a Deleted User

  • SharePoint site > Library settings > Manage checked-out files: Use this page to force a check-in for files locked by a deleted user.
  • PowerShell cmdlet Set-PnPFileCheckedIn: Use this command to check in a file when the SharePoint UI does not show the lock.
  • OneDrive sync client > Stop sync and reopen: A local sync lock can mimic a server-side lock; clear the sync cache to test.

ADVERTISEMENT

Why SharePoint Keeps the Lock After a User Is Deleted

When a user checks out a file in SharePoint, the system writes a lock entry tied to that user’s account ID. Deleting the user from Microsoft 365 does not automatically release the check-out lock. SharePoint treats the lock as an active file operation, and only a check-in action from the original account or a site admin can clear it.

The lock is stored in the SharePoint content database, not in the user’s profile. Even after the account is gone, the lock entry remains because SharePoint has no background job to clean up orphaned check-outs. This means the file appears locked to every other user, and the only way to unlock it is to force a check-in from the site collection administrator.

The Role of File Check-Out in SharePoint

File check-out is a SharePoint feature that prevents two users from editing the same document at the same time. When a user checks out a file, SharePoint locks it for that user alone. The lock stays until the user checks the file back in or discards the check-out. If the user is deleted before checking in, the lock becomes orphaned.

Why the Lock Does Not Appear in the UI

SharePoint admin tools do not show orphaned check-outs by default. The standard “Manage checked-out files” page in library settings may not list the file if the user account no longer exists. In that case, you need to use PowerShell or a direct URL to access the check-in function.

Steps to Release the Lock Using SharePoint Library Settings

  1. Open the SharePoint document library
    Navigate to the SharePoint site that contains the locked Excel file. Click on the document library name in the left navigation or from the site contents page.
  2. Access library settings
    Click the gear icon in the top-right corner and select “Library settings.” If you do not see this option, you need site owner or site collection administrator permissions.
  3. Open the Manage checked-out files page
    Under the “Permissions and Management” section, click “Manage checked-out files.” This page lists all files that are currently checked out by any user.
  4. Locate the locked Excel file
    Look for the file with the deleted user’s name in the “Checked Out To” column. If the user is deleted, the name may appear as a GUID or a blank entry.
  5. Force a check-in
    Select the checkbox next to the locked file. Click the “Check In” button at the top of the list. In the dialog, choose “Check In” without adding a comment. The file lock is released immediately.

ADVERTISEMENT

Steps to Release the Lock Using PowerShell

  1. Install SharePoint PnP PowerShell module
    Open Windows PowerShell as administrator and run: Install-Module PnP.PowerShell -Scope CurrentUser. If you already have the module, update it with Update-Module PnP.PowerShell.
  2. Connect to the SharePoint site
    Run Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive. Sign in with a site collection administrator account.
  3. Identify the locked file
    Run Get-PnPFile -Url "/sites/yoursite/Shared%20Documents/YourFile.xlsx" -AsFile to verify the file path. Note the server-relative URL.
  4. Force check-in the file
    Run Set-PnPFileCheckedIn -Url "/sites/yoursite/Shared%20Documents/YourFile.xlsx" -CheckinType MajorCheckIn. The file lock is released without requiring the original user account.
  5. Verify the lock is cleared
    Run Get-PnPProperty -Url "/sites/yoursite/Shared%20Documents/YourFile.xlsx" -Property CheckedOutUserId. If the result is empty, the file is no longer locked.

If the Lock Persists After the Main Fix

SharePoint Library Does Not Show the Checked-Out File

If the “Manage checked-out files” page is empty or does not list the locked file, the lock may be stored differently. This happens when the file was checked out from a sync client or via an older SharePoint version. Use the PowerShell method instead — it bypasses the UI and directly modifies the check-out status.

OneDrive Sync Shows the File as Locked

If the Excel file is synced to your local computer via OneDrive, the sync client may show a lock icon even after the server-side lock is cleared. Right-click the OneDrive icon in the system tray and select “Pause syncing” for two hours. Then resume syncing. If the icon remains, stop sync completely, restart the OneDrive app, and let it re-sync the library.

File Is Locked by “NT AUTHORITY\SYSTEM” or a Service Account

In rare cases, the lock shows as owned by a system account instead of a deleted user. This can happen when a workflow or Power Automate flow checked out the file and then failed. To release this lock, use the PowerShell method with the -Force parameter: Set-PnPFileCheckedIn -Url "..." -CheckinType MajorCheckIn -Force.

Item SharePoint Library Settings Method PowerShell Method
Permissions needed Site owner or site collection admin Site collection admin
UI availability Works only if the file appears in the Manage checked-out files page Works even if the file is not listed in the UI
Time to complete 2 to 3 minutes 5 to 10 minutes including module setup
Risk of data loss None — only releases the lock None — only releases the lock

After releasing the lock, open the Excel file in the browser or desktop app. The file should now be editable. If you manage many sites, consider setting a retention policy that alerts admins before deleting a user who has checked out files. You can run a weekly PowerShell script to find all checked-out files and force check-in for any orphaned locks. This prevents the problem from recurring.

ADVERTISEMENT