dsccommunity/xPSDesiredStateConfiguration

DSC registry resource support '/' in the registry path.

zjalexander opened this issue · 9 comments

If you use a path containing a / e.g. "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC2 40/128" then the builtin registry resource you end up with an error or the wrong registry path being created.

This config will not work. I've have to create my own module to create the folder and then us the registry resource to create the actual key.

Registry "DisableCipherRC240128" 
{ 
Key = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\RC2 40/128" 
ValueName = "Enabled" 
ValueType = "Dword" 
ValueData = "0" 
Ensure = "Present" 
Force = $true 
}

The register resource should support / in the path.

from uservoice: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/17239322-dsc-registry-resource-support-in-the-registry

Shouldn't the path be HKLM:\SYSTEM\... regardless of whether the forward slash isn't handled correctly?

Edit: nevermind, just checked the code

I was able to repro this using the Registry resource, however it looks like the team has already fixed this in the xRegistry resource (note the leading x). I tested the exact code, swapping Registry for xRegistry and the keys created just fine. I used xPSDesiredStateConfiguration resource 5.0.0.0.

bozho commented

Hi,

This does not work for me in xPSDesiredStateConfiguration 5.1.0.0 on Win Server 2012R2. I get 128 as a separate subkey.

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.0.10586.117
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10586.117
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Edit: To add to this, it looks like New-RegistryKey functions uses Split-Path to create necessary keys. Split-Path will split on forward slash.

bozho commented

Hi,

I've submitted a pull request for this issue: #306

Fixed by #306

hi i was experiencing this issue and then arrived at this page from googling. has the fix been incorporated into the normal PSDesiredStateConfiguration resource yet?

@ewhitesides We are no longer working on the PSDesiredStateConfiguration module, so this fix is not in those resources. Most PSDesiredStateConfiguration resources have been replaced by the ones in the open-source PSDscResources module which can be installed from the PowerShell Gallery. If you don't have WMF 5.1 yet, this fix is also in the xPSDesiredStateConfiguration module from the PowerShell Gallery.

@kwirkykat - In that case, why haven't the Visual Studio 2017 templates been updated to use one of the modules with the fix in it? Seems odd that the VS templates are adding a deprecated module by default.

image

image

In that case, why haven't the Visual Studio 2017 templates been updated to use one of the modules with the fix in it? Seems odd that the VS templates are adding a deprecated module by default.

We don't own those templates, but I've found the owner and I'm working with them to get the VS templates updated. Thanks for pointing that out! :)