Unsync OneDrive locally

(sorry if this topic is reposted, I type it up and really thought I submitted it…)

Long story short, I am trying to automate a few processes to reduce the hands on time required by our team migrating machines.

I am looking to (locally, via a script) turn off the OneDrive sync on win10 machines. I cannot find any local command to do this. When ever I search I get back cmdlets to manage the o365 account settings, not local stuff.

We’ll see if anyone else jumps in, but I’m unaware of a command to do so. I suppose you could try killing the process?

Killing the process only turn off the sync… which is kind of what I posted… Actually, I need to unsync the data. The manual steps would be as follows:

OneDrive - Settings | Accounts
Chose folders - remove all check marks (this basically says I no longer want local copies, saving disk space)
Unlink PC (this removed the define sync with the UPN)

Really, I could do the Unlink PC thing, then just blow away the sync folder as well. We are in the midst of a large domain merger (10000+ computers across multiple countries), and want to clean up as much as possible before the computer migrations. Any steps that can be automated would help out a lot.

Is this OD for business or OD personal?

The reason I ask, is because by design ODB is attached to the SPO license and the user is the admin of their ODB (which is noting more than a SP site collection), so, even if you did do this, they can just turn it back on, again they own this not the corporate admin.

You can’t for example disable ODB for a user without fully disabling the SPO license for that user. IN that later case, see this post.:

What no one tells you about disabling OneDrive for Business - Penthara Technologies

Also see:


This is OD4B, but this is not to prevent them from syncing. Over the weekend, in an office we are migrating their computers and accounts from one domain to the next.

The software we use basically moves their profile info from the old domain to the new. Problem is it just moves it. That means that when you log in to the new domain, OD4B sees the old UPN. We have to manually set up the new UPN (or a bit of code work I have in the works).
The problem is we need to get the old sync off the old domains so that when the new UPN syncs we are not doubling up on data (and the fact that OD4B cries that it cannot connect properly to the old UPN on boot up).

So really this is local scale only. just need to unsync on the win10 machine for the user before the migration happens.

I could see you doing a couple things…

First, if running Windows 10 1709, you can use attrib.exe inside of PowerShell to unpin all the files. That revert all files to online only copies (the cloud icon). This only works in 1709 or later as the file attributes don’t exist before then.

Second, there is a registry hive that is created when a user has their account linked in OD. You could try blowing away the entry for the business account. The registry is here if you want to try and play with it. I just tried it. I think it worked, but I have autoconfigure set up, so i think it just set my account up because I started it. I suspect though that this would work.

Then, you could try deleting the run reg key so that it doesn’t auto start for the user if so desired in this location, Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run.

I hope this helps a little.

This was the first reg location I forgot to paste.