0

I have a DSC pull server that work great but lately I expirance issues to update registey value on HKEY_CURRENT_USER in order to enable screen saver.

DCS Resource:

Registry ScreenSaveActive
      {
            Ensure = "Present"  
            Key = "HKEY_CURRENT_USER\Control Panel\Desktop"
            ValueName = "ScreenSaveActive"
            ValueData = "1"
            Force = $True
        }

When I am trying to any value in "HKEY_LOCAL_MACHINE" it worked.

any Idea how to resolved it or alternative way.

Thanks, Cfir.

cfircoo
  • 417
  • 2
  • 8
  • 23
  • I would assume the LCM is executing as system so HKCU is not the hive for the user logging on onto the server. What's wrong with using HKLM? – Lieven Keersmaekers Sep 07 '16 at 10:35
  • HKLM not overide HKCU. – cfircoo Sep 07 '16 at 10:38
  • I guess you are out of luck then. According to [this blog](https://blogs.technet.microsoft.com/heyscriptingguy/2015/02/06/use-powershell-dsc-to-configure-the-registry#entry-content), *DSC runs in a system context, and therefore, it does not have access to the current user registry hive (HKCU).* – Lieven Keersmaekers Sep 07 '16 at 11:04

1 Answers1

2

DSC runs in the context of local system. You will have to use RunAs with the desired user in order to access HKCU. This blog explains the feature in detail http://nanalakshmanan.com/blog/Understanding-RunAs/

Nana Lakshmanan
  • 741
  • 3
  • 6