-
Notifications
You must be signed in to change notification settings - Fork 5
onedrive_remove_complete.ps1
Corey Watson edited this page Dec 24, 2025
·
2 revisions
Performs a complete, multi-path uninstallation of Microsoft OneDrive with permanent startup suppression.
This script stops running processes, executes the official Microsoft uninstall utility against all known install paths (system and Office), removes scheduled tasks, and applies registry policies to prevent reinstallation.
Performs a complete, multi-path uninstallation of Microsoft OneDrive with permanent startup suppression. Stops running processes, executes the official Microsoft uninstall utility against all known install paths (system and Office), removes scheduled tasks, and applies registry policies to prevent reinstallation.
- PowerShell 5.1 or later
- Administrator privileges required
- No network requirements (local operations only)
- No runtime parameters required
- All operations use hardcoded paths and registry locations
- OneDrive Setup Paths: System32, SysWOW64, Office x86, Office x64
- Registry GPO Path: HKLM:\Software\Policies\Microsoft\Windows\OneDrive
- Registry Explorer Path: HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer
- Registry Run Key: HKCU:\Software\Microsoft\Windows\CurrentVersion\Run
- Hardcoded OneDriveSetup.exe paths (system and Office locations)
- Registry keys for GPO, Explorer, and Run persistence
- Task Scheduler for OneDrive scheduled tasks
- WMI/CIM for system diagnostics
- Validates administrative privileges
- Stops all running OneDrive processes
- Executes OneDriveSetup.exe /uninstall for each found path
- Removes all OneDrive scheduled tasks
- Sets HKLM GPO DisableFileSyncNGSC=1 to prevent startup for all users
- Removes HKCU Run key OneDrive entry
- Sets Explorer policy to hide OneDrive from navigation pane
- Reports completion status with reboot recommendation
- No secrets (API keys, passwords) are used or logged
- All actions confined to local files, registry, and task scheduler
- Registry modifications use Group Policy paths for proper enforcement
- 0 : Success - all cleanup steps completed
- 1 : Failure - critical error (likely permission-related)
[ INPUT VALIDATION ]
--------------------------------------------------------------
Computer Name : WKSTN-FIN-01
Username : SYSTEM
Admin Privileges : Confirmed
Paths to Check : 4
[ STOP PROCESSES ]
--------------------------------------------------------------
Stopping OneDrive processes...
OneDrive processes terminated
[ UNINSTALL ONEDRIVE ]
--------------------------------------------------------------
Checking path : C:\Windows\SysWOW64\OneDriveSetup.exe
Status : Found - executing uninstall
Result : Uninstall command completed
Checking path : C:\Windows\System32\OneDriveSetup.exe
Status : Not found - skipping
Checking path : C:\Program Files\Microsoft Office\root\...
Status : Not found - skipping
Checking path : C:\Program Files (x86)\Microsoft Office\root\...
Status : Not found - skipping
Uninstallers Run : 1
[ REMOVE SCHEDULED TASKS ]
--------------------------------------------------------------
Removing OneDrive scheduled tasks...
Scheduled tasks removed
[ REGISTRY CLEANUP ]
--------------------------------------------------------------
Setting HKLM GPO DisableFileSyncNGSC = 1
HKLM GPO policy applied
Removing HKCU Run key OneDrive entry
HKCU Run key cleaned
Setting Explorer DisableOneDriveFileSync = 1
Explorer policy applied
[ FINAL STATUS ]
--------------------------------------------------------------
Result : SUCCESS
Uninstallers Run : 1
OneDrive removal complete - reboot recommended for full cleanup
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
- 2025-11-29 v1.1.0 - Refactored to Limehawk Style A with improved validation, cleaner section organization, and enhanced error handling.
- 2025-09-19 v1.0.0 - Initial version for complete multi-path OneDrive uninstall.
- View Script Source
- Scripts - Back to script index