How to remove OneDrive from the Windows Explorer Navigation pane in Windows 8.1 (PowerShell)

Introduction

This script is to remove OneDrive from the Windows Explorer Navigation pane in Windows 8.1.

Scenarios

Some users want to remove OneDrive from the Windows Explorer Navigation pane due to some reasons.

Script

Step 1: Right click the script and select Run with administrator.

 

Step 2: Then after the script finishes execution, you will need to restart your computer to take effect.

Here are some code snippets for your reference:

PowerShell
Edit|Remove
New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT  -Name HKCR | Out-Null 
$Path = "HKCR:\CLSID\{8E74D236-7F35-4720-B138-1FED0B85EA75}\ShellFolder" 
$value = Get-ItemProperty -path $Path -Name Attributes 
if($value.Attributes -eq 4034920525{ 
    Set-ItemProperty -Path $path -Name Attributes -value 2668101709  
    write-host "You have removed the OneDrive from Windows explorer navigation, you need to restart computer to take effect." 
} 
Else 
{ 
    Set-ItemProperty -Path $path -Name Attributes -value 4034920525 
    write-host "You have added the OneDrive from Windows explorer navigation, you need to restart computer to take effect." 
} 
Restart-Computer -Confirm:$true

Prerequisite

Windows 8 or higher version

OneDrive

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.