Score:1

How to remove OneDrive via PowerShell

iq flag

Just wondering if anyone can successfully uninstall OneDrive using PowerShell on Windows 10/11. The uninstall flag on the executable doesn't remove it even if processes are killed first.

OneDriveSetup.exe /uninstall

The command doesn't appear to be doing anything. Need to uninstall the OneDrive that comes with the OS to install it in a way that its compatible using the machine wide installer Azure Virtual Desktop/AllUsersInstall. Manually uninstalling from control panel works but I need an unattended uninstall for Azure Image Builder.

Appreciate the help

Score:0
tk flag

I removed onedrive using powershell as follow:

# as you mentioned kill the onedrive prcess
taskkill /f /im OneDrive.exe

# uninstall the onedrive
# for x64 system (I tested it on my machine)
cmd -c "%SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall"

# for x86 machines
cmd -c "%SystemRoot%\System32\OneDriveSetup.exe /uninstall"
itocdw avatar
iq flag
Thanks for trying it. I ran those commands you provided via powershell as Admin and it just doesn't do the uninstall. Must be missing something...
Score:0
ru flag

By default, OneDrive is installed per user on all supported versions of Windows. But it can be installed per machine.

To find the uninstall command (string) for your system, you can look into the registry:

Per user installation:

  • Path : HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OneDriveSetup.exe
  • Key : UninstallString

Then you can use Powershell to uninstall it using the commands as in the previous answer:

# kill the OneDrive process
TASKKILL/F /IM OneDrive.exe

# Uninstall OneDrive using the UninstallString value found in registry, for example (may vary depending on OneDrive version):
cmd -c "C:\Users\<USERNAME>\AppData\Local\Microsoft\OneDrive\21.245.1128.0002\OneDriveSetup.exe /uninstall"

If the key is not present, most probably OneDrive is installed per computer so have a look here:

Per machine installation: (may vary depending on OneDrive version and flavor)

  • Path : HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OneDriveSetup.exe
  • Key : UninstallString

Additional information can be found here:

https://docs.microsoft.com/en-us/onedrive/per-machine-installation

itocdw avatar
iq flag
Thank you. It looks like that uninstall value has worked (HKLM). It also had the /allusers flag on the uninstall command so not sure if that made the difference or if it wanted that particular exe/onedrive path.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.