Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
700 views
in Technique[技术] by (71.8m points)

registry - How to Edit HKCU values with PowerShell

When I run the command to edit a registry value on HKCU with PowerShell, I have to run PS as an admin to have perms to edit the registry. Unfortunately, this changes HKCU to my admin account (as far as I can tell, at least), which keeps me from editing the user.

I need to automate this as we’re rolling out hundreds of machines. Am I missing something?

question from:https://stackoverflow.com/questions/66066661/how-to-edit-hkcu-values-with-powershell

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When running an elevated PowerShell, the user specific registry can be edited under HKEY_USERS<Users SID>.... For example:

Get-ItemProperty -Path "registry::hkey_users$($strSID.Value)SoftwarePoliciesMicrosoftWindowsControl PanelDesktop"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...