diff --git a/scripts/remove-onedrive.ps1 b/scripts/remove-onedrive.ps1 index 5263c35..f5aaa95 100644 --- a/scripts/remove-onedrive.ps1 +++ b/scripts/remove-onedrive.ps1 @@ -1,8 +1,6 @@ # Description: # This script will remove and disable OneDrive integration. -Import-Module -DisableNameChecking $PSScriptRoot\..\lib\reg-helper.psm1 - echo "Kill OneDrive process" taskkill.exe /F /IM "OneDrive.exe" taskkill.exe /F /IM "explorer.exe" @@ -22,22 +20,17 @@ rm -Recurse -Force -ErrorAction SilentlyContinue "$env:userprofile\OneDrive" rm -Recurse -Force -ErrorAction SilentlyContinue "C:\OneDriveTemp" echo "Disable OneDrive via Group Policies" -if (-Not (Get-Item -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive\" -ErrorAction SilentlyContinue)) { - New-Item -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive\" -} -Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\OneDrive\" -Name DisableFileSyncNGSC -Value 1 +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" -Import-Registry(@" -[HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}] -"System.IsPinnedToNameSpaceTree"=dword:00000000 - -[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}] -"System.IsPinnedToNameSpaceTree"=dword:00000000 -"@) +New-PSDrive -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" -Name "HKCR" +sp "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" "System.IsPinnedToNameSpaceTree" 0 +sp "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" "System.IsPinnedToNameSpaceTree" 0 +Remove-PSDrive "HKCR" echo "Removing startmenu entry" -rm -Recurse -Force -ErrorAction SilentlyContinue "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" +rm -Force -ErrorAction SilentlyContinue "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" echo "Restarting explorer" start "explorer.exe"