Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
How to handle key names for registry settings that are somewhat alike
-
I have a PSDsc configuration that I am having a problem with:
##AH:UseTextMode
PSDsc Registry
(
Otter_ConfigurationKey: Key,Key : "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1", ValueName : "1601", ValueType : 'Dword', ValueData : "1"
);
PSDsc Registry
(
Otter_ConfigurationKey: Key,Key : "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1", ValueName : "2100", ValueType : 'Dword', ValueData : "3"
);
PSDsc Registry
(
Otter_ConfigurationKey: Key,Key : "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", ValueName : "1601", ValueType : 'Dword', ValueData : "1"
);
PSDsc Registry
(
Otter_ConfigurationKey: Key,Key : "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", ValueName : "2100", ValueType : 'Dword', ValueData : "3"
);
This setting ensures IE harding of the security zones, but the trouble is two of they keys are the same, and two of the valuename or valuedata are the same as well. I have tried several combinations of trying to get the key to be more dynamic, but I can't seem to be able to work with Otter_ConfigurationKey: at all:
-Tried custom name, that doesn't work, must match a dsc property.
-tried an array like @('key','valuedata') as well as (@('key','valuedata') ), no dice there. Tried adding " " and ' ' just for kicks, no luck there.While I love guessing, I like knowing much better. Anyone have any ideas to get this to work?
Product: Otter
Version: 2.0.12
-
You should really be using the Ensure-RegistryValue operations for this, because it will do the exact same thing while being easier to maintain and visualize.
The Otter_ConfigurationKey must be unique per configurable item on the server. So, in this case, you should make a string based on the registry key+value. You can use the full key+value, or perhaps something like this:
PSDsc Registry ( Otter_ConfigurationKey: SecurityZones3_2100, Key : "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3", ValueName : "2100", ValueType : 'Dword', ValueData : "3" );
-
as I noted before, I cannot enter a name for it by myself due to this error:
ERROR:Unhandled exception: System.InvalidOperationException: The "SecurityZones1_1601" property of the DSC resource was not found. Use the "ConfigurationKey" argument for Ensure-DscResource or the "Otter_ConfigurationKey" argument for PSDsc to specify the property which uniquely identifies this resource on the server.
To me, if I am reading it correctly, limits to Otter_ConfigurationKey to a valid property of the DSCResource, meaning I can only use Key,ValueName, ValueData, etc as valid keys. Hence why the question. So if you try this on your test system, does it work? I would prefer to use the DSC as it is understood. Just so I know, on the Ensure-RegistryValue, how do you set the type of registry entry like string or dword?
-
Sorry, I misunderstood it myself and responded too quickly.
You're right, the OtterConfiguration_Key points to a DSC Property. It's not an alias, like I had assumed. But looking closer, I see that it is.
It seems this would require a feature/change request to fix; might not be so bad, but I'm not familiar enough w/ it to be certain.
-
Maybe it would be possible to add a another property to specify the name it should show up under configurations, similar to PSEnsure. In DSC, every DSC configuration is also set up as a unique name, so it should mirror that functionality IMHO.
For the Ensure-Registry, I would still like an answer to my question on the previous post.
Also, I have solved this issue for now using PSEnsure, which works great.
-
For Ensure-RegistryValue, you can use the
Kind
property to control the type:Ensure-RegistryValue ( Name: 2100, Value: 3, Kind: DWord, Hive: LocalMachine, Key: SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3 );
Valid values for this property are listed here.