Disable Microsoft Account Sync Using PowerShell
To disable Microsoft Account Sync using a PowerShell script, you can use the following script which will create a registry key to disable the sync:
# DisableMicrosoftAccountSync.ps1
# Run PowerShell as Administrator
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
# Create registry key to disable Microsoft Account Sync
$path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\SettingSync"
$key = "DisableSettingSync"
if (-not(Test-Path $path)) {
New-Item -Path $path -Force | Out-Null
}
Set-ItemProperty -Path $path -Name $key -Value 2 -Type DWord -Force
Write-Host "Microsoft Account Sync has been disabled successfully."
To execute this script, follow these steps:
- Open PowerShell with administrator privileges. To do this, search for "PowerShell" in the Start menu, right-click on "Windows PowerShell", and select "Run as administrator".
- Change the execution policy to allow running unsigned scripts if you haven't already. Run this command: "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser"
- Save the above script in a file named "DisableMicrosoftAccountSync.ps1" on your computer.
- Navigate to the directory where you saved the script, for example: "cd C:\Users\<YourUsername>\Desktop"
- Run the script by typing .\DisableMicrosoftAccountSync.ps1 and pressing Enter.
This will disable the Microsoft Account Sync on your computer. If you want to re-enable it later, just change the value of "-Value" from "2" to "0" in the script and run it again.
Comments
Post a Comment