0

I'd like to overwrite an existing registry key in HKCU for all users on this device with Desired State Configuration.

I already found, that I could use the users credentials(Configuring HKEY_CURRENT_USER with DSC Resource actually updates HKEY_USERS\.DEFAULT), but I do not have them.

Any ideas?

theq
  • 111
  • 2
  • 10
  • `HKEY_CURRENT_USER` is just an alias for the appropriate subkey in `HKEY_USERS`, depending on who's logged into the session. If you want to change something for all users, just go through all subkeys of `HKEY_USERS`. – Jeroen Mostert Aug 23 '17 at 15:03
  • 1
    @JeroenMostert Your last statement is potentially misleading. HKEY_USERS would only have _loaded_ hives. So if there was a user not signed in that needed the change it would not find them. – Matt Aug 23 '17 at 15:14
  • @Matt: which makes the conclusion, I guess, "use Group Policy instead". Because you probably don't want to deal with things like roaming profiles of users not currently logged in... at least not with DSC. – Jeroen Mostert Aug 23 '17 at 15:22
  • @JeroenMostert GPO would be the way to go yes. – Matt Aug 23 '17 at 15:22
  • Just chiming in: registry edits for all users should not be handled by DSC/Scripts unless done through login scripts or GPO. Otherwise you run into very obscure issues (as it's not done very often, for good reason) – Maximilian Burszley Aug 23 '17 at 17:45

1 Answers1

0

Technically if your administrator on the Box you can still do this, Load their Registery Hive and Change a Key.

$Username = "TestUser"
reg load hku\$Username C:\Users\$Username\NTUSER.DAT
New-PSDrive -Name $Username -PSProvider Registry -Root HKU\$Username
Set-Location "$($Username):\Control Panel\desktop\colors"
Get-ItemProperty -Path. -Name ActiveBorder
Set-ItemProperty -Path. -Name ActiveBorder -Value "218 208 200"
Get-ItemProperty -Path. -Name ActiveBorder
Remove-PSDrive -Name $Username -Force
ArcSet
  • 6,518
  • 1
  • 20
  • 34