-
Notifications
You must be signed in to change notification settings - Fork 1
/
Remove-OneDrive.ps1
27 lines (21 loc) · 999 Bytes
/
Remove-OneDrive.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
######
#
# Remove-OneDrive.ps1
#
# Source: https://github.com/LeDragoX/Win-Debloat-Tools/blob/main/src/scripts/Remove-OneDrive.ps1
#
###
[CmdletBinding()]
Param()
Get-Process 'OneDrive' -ErrorAction SilentlyContinue | Stop-Process
& "$env:systemroot\System32\OneDriveSetup.exe" /uninstall
Remove-Item -Recurse -Force "$env:localappdata\Microsoft\OneDrive" -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force "$env:programdata\Microsoft OneDrive" -ErrorAction SilentlyContinue
# Remove new users hook (Matthew Israelsson)
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"
# Remove Start Menu link
Remove-Item -Force -ErrorAction SilentlyContinue "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
# Remove OneDrive user folder (if empty)
Remove-Item "$env:userprofile\OneDrive" -Recurse -Force -ErrorAction SilentlyContinue