How to Force-Close Open Files and Sessions on a Shared OneDrive Site
Question details
The user needs to disconnect active users on a company-wide OneDrive or SharePoint site to safely rename folders and files without hitting file lock errors.

- Product
- OneDrive and SharePoint
- Device & OS
- not provided
- Scenario
- Administrators need to rename shared folders with long paths on a company site, which requires signing active users out to prevent synchronization conflicts.
- Observed behavior
- Active user sessions maintain file locks, preventing administrators from renaming, moving, or modifying shared folders and files.
Before forcefully disconnecting users, ensure you notify your team to save their work and pause any active uploads to prevent potential data loss or version conflicts.
Use PowerShell to Disconnect Active SharePoint Sessions
Use the Revoke-SPOUserSession command in SharePoint Online Management Shell to sign out specific users before making administrative changes.
The Revoke-SPOUserSession command provides a controlled way to disconnect a user's active SharePoint and OneDrive sessions. This is critical when users must be signed out before wide-scale folder renames or when an account is suspected to be compromised.
Right-click the Windows Start button, select Windows PowerShell (Admin), and ensure you have the SharePoint Online Management Shell module installed.
Type the command Connect-SPOService -Url https://[yourtenant]-admin.sharepoint.com and press Enter. Sign in with your global administrator or SharePoint administrator credentials.
Execute the command Revoke-SPOUserSession -User user@yourcompany.com. Confirm the prompt to immediately sign the user out across all devices.
Wait a few minutes for the session revocation to propagate, then proceed to rename your folders and files in the SharePoint or OneDrive admin center.

Experience Seamless Team Collaboration with WPS Office
While managing shared files on SharePoint and OneDrive can require complex PowerShell commands, WPS Office offers a highly compatible alternative with intuitive built-in cloud sharing and easy access management.

Frequently Asked Questions
Will users need to resynchronize their local files after a root folder is renamed?
Yes. If an administrator renames a shared root folder or reshapes the directory structure, affected users will usually need to unsync the old OneDrive path and establish a new sync connection to the newly renamed folder.
Can I disconnect all users at once instead of one by one?
The Revoke-SPOUserSession command targets individual users by default. To disconnect multiple users, an administrator must write a PowerShell script using a loop that processes a list of active user accounts.
How long does it take for a user session to close after running the command?
Session revocation generally takes effect within a few minutes. However, in some Office 365 environments, it can occasionally take up to an hour for the disconnection to propagate fully across all connected devices and services.




