Account Security Problems

How to Force-Close Open Files and Sessions on a Shared OneDrive Site

Ayan MasoodAyan Masood Oct 9, 2026 868 views

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.

How to Force-Close Open Files and Sessions on a Shared OneDrive Site
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 you start

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.

Solution 1Recommended

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.

1
Open PowerShell as Administrator

Right-click the Windows Start button, select Windows PowerShell (Admin), and ensure you have the SharePoint Online Management Shell module installed.

2
Connect to SharePoint Online

Type the command Connect-SPOService -Url https://[yourtenant]-admin.sharepoint.com and press Enter. Sign in with your global administrator or SharePoint administrator credentials.

3
Revoke the User Session

Execute the command Revoke-SPOUserSession -User user@yourcompany.com. Confirm the prompt to immediately sign the user out across all devices.

4
Rename the Target Folders

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.

Use PowerShell to Disconnect Active SharePoint Sessions
Synchronization Considerations: After renaming folders, you may need to temporarily remove sharing and share the root folder again. Users might have to stop syncing the old folder path and resynchronize their local OneDrive clients.
Free Microsoft Office alternative

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.

Fully compatible with Microsoft Office formats, including .docx, .xlsx, and .pptx.Built-in WPS Cloud allows for easy real-time collaboration and link sharing without complex backend administration.Free and lightweight design that runs smoothly on Windows, Mac, Linux, and mobile devices.Intuitive user interface that requires no PowerShell scripting for basic file and user management.
QA img-9

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.