I’m trying to change the default value for a key. When I try do this with the Registry Resource it simply creates a “second” (Default) value in key. Is it a bug or am I doing it wrong?
The “(Default)” isn’t a discrete value - that is, it isn’t an ItemProperty the way other values are. For example, in the shell, you’d do this to set a key’s default value:
You’re just setting the value of the key itself - not creating a new ItemProperty. So you don’t specify a ValueName.
The problem is that the Registry resource mandates ValueName - which sort of suggests that it can’t work with keys (“items”) but only with values (“item properties”). If it can’t directly modify a key, then there’s no way to set the default value.
You could probably work around this by using a Script resource, and using Get-Item and Set-Item in the Test{} and Set{} script blocks.
The default value is actually an empty value name, but of course, MOF doesn’t allow you to have empty strings assigned to Key properties.
In a similar resource I wrote for modifying local GPO registry.pol files, I worked around this problem by combining the key / value names into a single Key property. If you wanted to modify the default value, you’d just specify a key path with a trailing backslash. This might be a good thing to log on Connect, or to add in the form of an xRegistry resource down the road.