Created
September 21, 2023 03:23
-
-
Save stu43005/6c598c5a37fdc4c89cd512588ded6fd5 to your computer and use it in GitHub Desktop.
Unlock OneDrive if it is disabled by company or school group policies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$regpath = "HKLM:\Software\Policies\Microsoft\Windows\OneDrive" | |
$regname = "DisableFileSyncNGSC" | |
$OneDriveExe = $Env:LocalAppData + "\Microsoft\OneDrive\OneDrive.exe" | |
$value = Get-ItemPropertyValue -Path $regpath -Name $regname -ErrorAction SilentlyContinue | |
if ($value -eq 1) | |
{ | |
$command = '-noprofile -command "Set-ItemProperty -Path {0} -Name {1} -Value 0 -ErrorAction SilentlyContinue"' -f $regpath,$regname | |
Start-Process powershell.exe -Wait -Verb RunAs -ArgumentList $command | |
} | |
$process = @(Get-Process OneDrive -ErrorAction SilentlyContinue).count | |
if ($process -eq 0) | |
{ | |
Start-Process -FilePath $OneDriveExe | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment