Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Uninstall OneDrive per user package

I know that PDQ has a package for uninstalling some programs such as Google Chrome that were installed on a per user basis, using Powershell. I'm just curious if anyone has something similar for uninstalling all instances of Microsoft OneDrive on a machine? I can do a per user uninstall if the specific user is logged in, but I'm looking for something to capture and uninstall for all users, current and past, on the machine. Can anyone offer some help? Thanks in advance.



Date Votes
  • This works for me, although most stations it throws an error on the first line that the Process wasn't found, but this has removed it for any local Windows accounts that have previously logged on, or for a new user logging on.

    #Import-Module -DisableNameChecking $PSScriptRoot\..\lib\force-mkdir.psm1
    #Import-Module -DisableNameChecking $PSScriptRoot\..\lib\take-own.psm1

    echo "73 OneDrive process and explorer"
    taskkill.exe /F /IM "OneDrive.exe"
    #taskkill.exe /F /IM "explorer.exe"

    echo "Remove OneDrive"
    if (Test-Path "$env:systemroot\System32\OneDriveSetup.exe") {
        & "$env:systemroot\System32\OneDriveSetup.exe" /uninstall
    if (Test-Path "$env:systemroot\SysWOW64\OneDriveSetup.exe") {
        & "$env:systemroot\SysWOW64\OneDriveSetup.exe" /uninstall

    echo "Disable OneDrive via Group Policies"
    mkdir -force "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive" 
    sp "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive" "DisableFileSyncNGSC" 1

    echo "Removing OneDrive leftovers trash"
    rm -Recurse -Force -ErrorAction SilentlyContinue "$env:localappdata\Microsoft\OneDrive"
    rm -Recurse -Force -ErrorAction SilentlyContinue "$env:programdata\Microsoft OneDrive"
    rm -Recurse -Force -ErrorAction SilentlyContinue "C:\OneDriveTemp"

    echo "Remove Onedrive from explorer sidebar"
    New-PSDrive -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" -Name "HKCR"
    mkdir -Force "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
    sp "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" "System.IsPinnedToNameSpaceTree" 0
    mkdir -Force "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
    sp "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" "System.IsPinnedToNameSpaceTree" 0
    Remove-PSDrive "HKCR"

    echo "Removing run option for new users"
    reg load "hku\Default" "C:\Users\Default\NTUSER.DAT"
    reg delete "HKEY_USERS\Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f
    reg unload "hku\Default"

    echo "Removing startmenu junk entry"
    rm -Force -ErrorAction SilentlyContinue "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"

    #echo "Restarting explorer..."
    #start-process "explorer.exe"

    echo "Wait for EX reload.."
    sleep 15

    echo "Removing additional OneDrive leftovers"
    foreach ($item in (ls "$env:WinDir\WinSxS\*onedrive*")) {
        Takeown $item.FullName
        rm -Recurse -Force $item.FullName

    However, and I may be preaching to the choir, check your Windows Updates so they don't re-enable it, as well as when/if you do a Feature Update (ex. 1903 to 1909/2004), it will enable almost all disabled Windows built-in applications.


  • Wouldn't GPO work better at this?

  • I may be completely wrong, but the GPO settings will prevent future setups, but not erase old setups.

  • The script actually did not work for me, again except for the currently logged in user. When i attempted to run this against a machine that had previous installations, It errored and actually added a new instance under the local admin account. 


  • I used decrapify (if you google it, you should be able to find it) and modified it on what I wanted installed and not installed. After each win10 workstation I run new workstation job that run the decrapify script and bunch of other things that i want installed.

  • Again...and I may be wrong, this works great to prevent future installs, but does it remove existing installations for all users?

  • good question, I haven't tested that. Can you be the beta tester :)