DSC Configuration to disable Visual Effects

I am trying to optimize the Windows OS by disabling the Visual effects. Well setting Visual Effects value to ‘adjust to best performance’ to be exact. I am using the following Configuration Script:

[pre]
Configuration OSConfig
{
param
(
[parameter()]
[string]
$NodeName = ‘localhost’
)

It is best practice to always directly import resources, even if the resource is a built-in resource.

Import-DSCResource -Name WindowsClient
Import-DscResource -Name Registry

Node $NodeName
{

The name of this resource block, can be anything you choose, as long as it is of type [String] as indicated by the schema.

Registry VisualEffects
{
Ensure = “Present”

Key = “HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects”

ValueName = “VisualFXSetting”

ValueData = “2”

ValueType = “Dword”

}
}

}

[/pre]
What i Expects this to do is, it should create a VisualFXSetting property under the Visual Effects Key and set its value to 2. But this is not happening after i run the Start-DscConfiguration Command. Is this the way to do it?

DSC is running as the System user, so HKCU will be for that user, probably not what you’d expect.

DSC is not really made for changing User specific GPOs, being mainly targeted at Servers.

It is possible to some extent, but a bit of a faff.

[quote quote=143324]DSC is running as the System user, so HKCU will be for that user, probably not what you’d expect.

DSC is not really made for changing User specific GPOs, being mainly targeted at Servers.

It is possible to some extent, but a bit of a faff.

[/quote]
So I should use HKLM instead of HKCU?

I just want to create a DSC Configuration and generate a mof, which i can apply on the plane vanilla OS to optimize its performance. One of the things i Want to do is disable the visual effects. Yes i can achieve this by just running a powershell script, but i want to configure OS at phase 2 of manufacturing, say when a machine comes with already installed golden/master image,i should be just able to place this mof file in that machine and start the DSC configuration.

Is this not the way to do it? I am very new to Powershell DSC. So still exploring.

So I should use HKLM instead of HKCU?

I just want to create a DSC Configuration and generate a mof, which i can apply on the plane vanilla OS to optimize its performance. One of the things i Want to do is disable the visual effects. Yes i can achieve this by just running a powershell script, but i want to configure OS at phase 2 of manufacturing, say when a machine comes with already installed golden/master image,i should be just able to place this mof file in that machine and start the DSC configuration.

Is this not the way to do it? I am very new to Powershell DSC. So still exploring.

Sorry, I was on mobile when I replied earlier, so wasn’t very clear.

The problem here is not really specific to DSC, but to how the Windows Registry works, and what HKCU is and mean…

You are trying to set a ‘User specific setting’ (VisualEffects is per-user, not for every account on a machine), during OS configuration (I assume, before user provisioning on that machine).
First of all, if the user account is created on that machine after you set this registry, that new account won’t get the settings… (because it’s per USER and that user wasn’t there).

Now assuming the account exists on the machine already, it’s probably not what DSC is running as… The DSC Service is running as SYSTEM (a special user account).
When you log in the machine manually, say as localhost\Administrator for the sake of the argument, HKCU (which means HKEY Current User) is mapped to the registry hive of that specific user (that you can find in HKEY_USERS). Should you be logged in as another account, HKCU will be pointing at another user’s hive… So DSC is probably changing the configuration of your SYSTEM user, just not on the account you expected.

So what you’re trying to do is the wrong approach for User Settings, you should probably be using GPOs. But the DSC code you posted is valid, and probably does what it’s meant to do.