OneDrive File Issues

Unlink a OneDrive for Business Account from the Command Line

John WilsonJohn Wilson Nov 20, 2026 868 views

Question details

Find a way to unlink a OneDrive for Business account using the command line or an alternative method.

Unlink a OneDrive for Business Account from the Command Line
Product
OneDrive for Business
Device & OS
not provided
Scenario
The user wants to automate removal of a business account from the OneDrive sync client.
Observed behavior
OneDrive for Business does not provide a standard command-line unlink command in the described scenario.
Before you start

Identify the business account email address and sign in to the Windows user profile that owns the OneDrive connection. Registry edits affect that profile; export the specific key before changing it and check whether your organization manages the account.

Solution 1Recommended

Unlink the business account in OneDrive settings

Use the supported graphical option when command-line automation is not essential.

1
Open OneDrive settings

Select the OneDrive cloud icon in the Windows notification area, select the gear icon, and choose Settings.

2
Find the account

Open the Account tab and locate the business account you want to disconnect.

3
Unlink the PC

Select Unlink this PC for that account and confirm Unlink account. Check the Account tab to verify the connection is gone.

Unlink the business account in OneDrive settings
Local files: Unlinking stops syncing for the account but does not automatically delete its local files. Cloud-only files may no longer be available locally after disconnection.
Free Microsoft Office alternative

Work with Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface and compatibility with common Microsoft Office formats, making it easy to move your document work to WPS. It does not unlink or repair OneDrive accounts.

Open local documents after managing your OneDrive connectionCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar editing tools for an easier transitionFree and lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Is there a standard OneDrive command-line unlink command?

There is no standard unlink command for the scenario described. The supported approach is to open OneDrive Settings, select Account, and choose Unlink this PC for the relevant account.

How do I identify the correct Business registry key?

In the affected Windows profile, inspect the keys under HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts and compare each Business key's UserEmail value with the intended account. Do not rely on the Business number alone.

Will deleting the account registry key fully unlink OneDrive?

Not necessarily. Registry removal is unsupported and may leave credentials or File Explorer entries behind. Use OneDrive Settings > Account > Unlink this PC when possible.

Does unlinking delete my files?

Unlinking stops synchronization but does not automatically delete local files. Files stored only in the cloud may no longer be available locally after the account is disconnected.

What should I do if the account returns after removal?

Check OneDrive Settings > Account and contact your organization's administrator. An organizational policy or another sign-in process may be reconnecting the account.