Configuring HKEY_CURRENT_USER with DSC Resource actually updates HKEY_USERS\.DEFAULT

送分小仙女□ 提交于 2019-12-24 01:53:22

问题


The following DSC declaration writes to Registry key HKEY_USERS.DEFAULT\Console instead of HKEY_CURRENT_USER\Console. Why?

Registry ConsoleFaceName
{
  Key         = 'HKEY_CURRENT_USER\Console'
  ValueName   = "FaceName"
  ValueData   = "Lucida Console"
  Ensure      = "Present"
}

回答1:


The behavior of writing to .DEFAULT is because the DSC Local Configuration Manager (LCM) is running as local system, which does not have a current user registry hive.

If you want it to update a particular user you need to run using PsDscRunAsCredential (docs linked), where $Credential is the credentials from the user you want to change the value for.

Registry ConsoleFaceName
{
  Key                   = 'HKEY_CURRENT_USER\Console'
  ValueName             = "FaceName"
  ValueData             = "Lucida Console"
  Ensure                = "Present"
  PsDscRunAsCredential  = $Credential
}

Before doing this please read Securing the MOF File.



来源:https://stackoverflow.com/questions/42124923/configuring-hkey-current-user-with-dsc-resource-actually-updates-hkey-users-def

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!