Skip to main content

Disable Personal OneDrive Sync

Summary

Disables personal Microsoft OneDrive account synchronization for all users on the machine.

Sample Run

Image

Task Creation

Script Details

Step 1

Navigate to AutomationTasks
step1

Step 2

Create a new Script Editor style task by choosing the Script Editor option from the Add dropdown menu
step2

The New Script page will appear on clicking the Script Editor button:
step3

Step 3

Fill in the following details in the Description section:

Name: Disable Personal OneDrive Sync
Description: Disables personal Microsoft OneDrive account synchronization for all users on the machine.
Category: Custom

Image

Row 1 Function: PowerShell Script

Search and select the PowerShell Script function.

PowerShell Function Selected

The following function will pop up on the screen:
PowerShell Function Example

Paste in the following PowerShell script and set the Expected time of script execution in seconds to 300 seconds. Click the Save button.

<#
.SYNOPSIS
Disables personal Microsoft OneDrive account synchronization for all users on the machine.

.DESCRIPTION
This script configures the OneDrive policy setting 'DisablePersonalSync'
under HKLM:\SOFTWARE\Policies\Microsoft\OneDrive.

By applying the policy at the machine level, the restriction applies to all
existing users and any future users who log on to the device.

The script creates the required registry path if it does not exist and sets
the DisablePersonalSync DWORD value to 1.

.NOTES
Registry Path:
HKLM:\SOFTWARE\Policies\Microsoft\OneDrive

Registry Value:
DisablePersonalSync (DWORD)

Value Meanings:
0 = Allow personal OneDrive accounts
1 = Prevent personal OneDrive accounts

.REQUIREMENTS
- Administrative privileges.
- Windows system with Microsoft OneDrive installed or managed.
#>

$registryPath = 'HKLM:\SOFTWARE\Policies\Microsoft\OneDrive'

try {
if (-not (Test-Path $registryPath)) {
New-Item -Path $registryPath -Force -ErrorAction Stop | Out-Null
}

New-ItemProperty `
-Path $registryPath `
-Name 'DisablePersonalSync' `
-PropertyType DWord `
-Value 1 `
-Force `
-ErrorAction Stop | Out-Null

return 'Success - DisablePersonalSync has been configured for all users.'
}
catch {
throw "Failed to configure DisablePersonalSync policy. Error: $($_.Exception.Message)"
}

Image

Row 2 Function: Script Log

Add a new row by clicking the Add Row button.
Add Row

A blank function will appear.
Blank Function

Search and select the Script Log function.
Script Log Search

In the script log message, simply type %output% and click the Save button.
Script Log Save

Save Task

Click the Save button at the top-right corner of the screen to save the script.
SaveButton

Completed Task

Image

Output

  • Script Logs

Changelog

2026-06-04

  • Initial version of the document