|
|
|
# Description:
|
|
|
|
# This script will remove and disable OneDrive integration.
|
|
|
|
|
|
|
|
echo "Kill OneDrive process"
|
|
|
|
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 "Removing OneDrive leftovers"
|
|
|
|
rm -Recurse -Force -ErrorAction SilentlyContinue "$env:localappdata\Microsoft\OneDrive"
|
|
|
|
rm -Recurse -Force -ErrorAction SilentlyContinue "$env:programdata\Microsoft OneDrive"
|
|
|
|
rm -Recurse -Force -ErrorAction SilentlyContinue "$env:userprofile\OneDrive"
|
|
|
|
rm -Recurse -Force -ErrorAction SilentlyContinue "C:\OneDriveTemp"
|
|
|
|
|
|
|
|
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 "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 startmenu entry"
|
|
|
|
rm -Force -ErrorAction SilentlyContinue "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
|
|
|
|
|
|
|
|
echo "Restarting explorer"
|
|
|
|
start "explorer.exe"
|