Windows Server  ·  low  ·  Storage, SAN & file services

A file is locked open by a user who has gone home

A session is holding the file open. The lock can be cleared from the server without restarting anything.

What you see

"The document is locked for editing by another user" naming somebody who is not there, or a file that cannot be moved or deleted.

What is actually wrong

A workstation that lost its network connection without closing the file, a crashed application, or an opportunistic lock that was never released.

Codes and articles

file in uselocked for editingGet-SmbOpenFileClose-SmbOpenFileoplock

The fix

Find and close the handle
Elevated PowerShell on the file server15 minutesmedium riskreversible

A specific file is locked.

  1. Find the open handle and who holds it.

    PowerShell
    Get-SmbOpenFile | Where-Object Path -like '*budget*' | Format-Table SessionId,ClientComputerName,ClientUserName,Path -AutoSize
  2. Check whether the user is genuinely gone before closing it — closing a handle on a file somebody is actively editing loses their unsaved work.

    PowerShell
    Get-SmbSession | Where-Object ClientUserName -like '*jbloggs*' | Format-Table ClientComputerName,ClientUserName,NumOpens,SecondsIdle

    The SecondsIdle figure is the deciding number. A session idle for hours is safe to close; one idle for seconds belongs to someone typing into the document right now.

  3. Close the specific handle.

    PowerShell
    Get-SmbOpenFile | Where-Object Path -like '*budget*' | Close-SmbOpenFile -Force
  4. If the lock persists, close the whole session for that machine.

    PowerShell
    Get-SmbSession -ClientComputerName WS042 | Close-SmbSession -Force
  5. For Office files, check for an orphaned owner file, which keeps the lock message appearing even after the handle is gone.

    PowerShell
    Get-ChildItem '\\fs01\share' -Recurse -Force -Filter '~$*' -ErrorAction SilentlyContinue | Format-Table FullName,LastWriteTime
  6. If this happens frequently to the same share, look at whether the clients are losing connectivity — repeated orphaned locks are a network symptom, not a file server one.

Confirm it workedThe file opens for editing and no handle remains.
PowerShell
Get-SmbOpenFile | Where-Object Path -like '*budget*'
If you need to undo itNone — the handle is gone. Any unsaved work in that session is lost, which is why the idle check matters.

Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.