uninstall_oo.ps1

Source: https://code.ravendevteam.org/talon/uninstall_oo.ps1

Overview

This PowerShell script uninstalls OneDrive and Outlook from Windows 11 systems by stopping related processes, removing Appx packages, deleting shortcuts and registry entries, and restarting Explorer.

Purpose & Use Cases

Remove built-in OneDrive and Outlook in enterprise or managed environments to enforce organizational policies.

Prepare Windows 11 machines for deployment in kiosk or thin-client setups without consumer applications.

Dependencies

Windows 11 with PowerShell and Appx module support

Administrative privileges to modify system packages, files, and registry

Configuration & Parameters

Parameter Type Description Default
None This script does not accept any command-line parameters.

Usage Example

powershell.exe -NoProfile -ExecutionPolicy Bypass -File uninstall_oo.ps1

Behavior & Implementation

Upon execution, the script checks for administrative rights and relaunches itself with elevation if necessary. It sets the execution policy to Bypass and silences errors. It closes any running Outlook processes, removes Outlook Appx packages and their online provisions, and deletes desktop and Start Menu shortcuts. It then cleans up taskbar pinned items and shell layout caches. For OneDrive, it invokes the OneDriveSetup.exe uninstall command from both 32-bit and 64-bit system paths, removes OneDrive application folders and data directories, and deletes associated CLSID registry entries from both HKCR and HKCU. Finally, it restarts Explorer to apply changes.

Error Handling

The script wraps operations in a try/catch block and uses $ErrorActionPreference = 'SilentlyContinue' to suppress non-terminating errors. Elevation failures cause an immediate exit.

Security Considerations

Requires administrative privileges and temporarily sets the execution policy to Bypass for the process scope only. No user input is accepted, minimizing injection risk. Ensure the script is obtained from a trusted source before execution.

Logging

The script does not emit logs; all errors are suppressed. To debug, modify or remove $ErrorActionPreference and add explicit logging as needed.

Testing & Validation

Run in a controlled Windows 11 VM, verify Outlook and OneDrive are uninstalled, and ensure no residual files or registry entries remain. Test reinstallation from Microsoft’s website.

Author

Author: Raven Development Team