0

Some users are experiencing problems with their OneDrive therefore we need to change the D word in Regedit to 0.

Set-ItemProperty -Path "HKEY:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Type DWord -Name "DisableFileSyncNGSC" -value 0

For HKEY_LOCAL_MACHINE you can only change it by running the regedit as admin.

I would like to have this scripted so it runs from my admin account, my admin credentials should be stored somewhere and when the user open/run the file on my public folder the regkey has been changed.

Is this possible?

2
  • 2
    avoid this scenario because it will be hard to proctect your credentials. you can simply update thsi key by using GPO/Preferences or you setup the script as scheduled task and configure the task to runs as LOCAL SYSTEM. one other solution is, that you execute the script which connects by using PowerShell remoting to the machines and updates the registry key. Commented Sep 9, 2022 at 12:32
  • The last one seems do-able to me. How can I do this? Commented Sep 9, 2022 at 12:40

1 Answer 1

0
#This variable must contain a list of dnsHostNames of the computer to connect to
$computers

#Defines the scriptblock to execute on the remote computer
$code = {
    Set-ItemProperty -Path "HKEY:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Type DWord -Name "DisableFileSyncNGSC" -value 0
}

#Runs the defined scriptblock on the specifed computers
invoke-command -ComputerName $computers -ScriptBlock $code

PowerShell Remoting (Enable-PSRemoting) must be enabled and you must have Admin Rights on the target machines. You can also use the parameter -credential to specify an alternate identity.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.