scloud by Florian Salzmann
ende

Remove OneDrive Personal from Explorer

Ever noticed too many OneDrive icons causing confusion on your Windows devices?
I’ve got you covered! This quick guide explains how to remove the extra OneDrive personal icon in the Explorer using a simple PowerShell script. No fuss, just straightforward steps, with the option to use just the script or a Proactive Remediation package.

The Script to Remove OneDrive Personal

In summary, the script checks for the presence of the OneDrive Personal Icon registry key on the desktop, and if found, it removes it and logs the action. If not found, it logs that the icon was not found. The script records its entire execution process in a transcript log file.

$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"
$logFilePath = "C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\Remove-OneDrivePersonal-script.log"

Start-Transcript -Path $logFilePath

if (Test-Path -Path $registryPath) {
    try {
        Remove-Item -Path $registryPath -Force -Verbose
        Write-Output "OneDrive Personal removed. "
    }
    catch {
        Write-Error "Error: $($_.Exception.Message)"
    }
}
else {
    Write-Output "All good, OneDrive Personal is already hidden."
}

Stop-Transcript

To deploy the script in Microsoft Intune just save it locally, upload and assign it under:
Intune > Devices > Windows >PowerShell scripts > +Add

Intune, add PowerShell Script

Intune, PowerShell script Remove-OneDrivePersonal

Proactive Remediation

For the Proactive Remediation, to remove the OneDrive Personal icon form the Explorer, you can use the same Script as Remediation, for the Detection you can use this:

$registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{018D5C66-4533-4307-9B53-224DE2ED1FE6}"

if (Test-Path -Path $registryPath) {
    try {
        Write-Output "OneDrive Personal is visible"
        exit 1
    }
    catch {
        Write-Error "Error: $($_.Exception.Message)"
        exit 1
    }
}
else {
    Write-Output "All good, OneDrive Personal is already hidden."
    exit 0
}

Summary

I wish there weas a policy for this. But at least with this script it’s not a big deal to hide the OneDrive Personal icon from the Windows Explorer.
If you like you could also create a Win32 package out of the script,. But for me it was always enough to deploy the script initially with Intune. The Proactive Remediation package is great to monitor the stat, but unfortunately not possible for Users licensed with the Microsoft 365 Business Premium license.

Related posts

Lenovo SmartSense locking your screen? Fix it with Intune.
(Proactive) Remediations

Fix Lenovo SmartSense Screen Locking via Intune Proactive Remediation

Fix Lenovo devices that auto-lock or dim when users look away using an Intune Proactive Remediation targeting the SmartSense service. Step-by-step guide with detection and remediation scripts.

Shortcut Deployment Options with Intune
(Proactive) Remediations

Deploying Shortcuts with Intune: Your Options

Deploy shortcuts with Intune using Platform Scripts, Remediations or Win32 apps. Covers Start Menu links, file shortcuts and the trade-offs of each method.

Free up space for Windows 11 upgrades with Intune Remediation
(Proactive) Remediations

Free up space for Windows 11 upgrades with Intune Remediation

Learn how to use Intune Proactive Remediation to detect and fix low disk space before a Windows 11 upgrade with a user friendly popup.