Skip to content

RegistryPolicies: Error when Key or ValueName parameters contain bracket "()" #172

@NicolasBn

Description

@NicolasBn

Problem description

When Key or ValueName parameters contain bracket "()", the compilation failed because RegistryPolicies resource doesn't replace bracket in $executionName. And that cause trouble in DependsOn parameter for RefreshRegistryPolicy resource.

For exemple :

RegistryPolicies Test {
	GPupdateInterval = 30
	Values = @(
		@{
			Key = "Software\Policies\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Restrict_ActiveXInstall"
			ValueName = '(Reserved)'
			TargetType = 'ComputerConfiguration'
			ValueData = '1'
			ValueType = 'String'
			Ensure = 'Present'
		},
		@{
			Key = "Software\Policies\Microsoft\Internet Explorer\Main\FeatureControl\Feature_Restrict_ActiveXInstall"
			ValueName = 'explorer.exe'
			TargetType = 'ComputerConfiguration'
			ValueData = '1'
			ValueType = 'String'
			Ensure = 'Present'
		}
	)

Verbose logs

No verbose log.

DSC configuration

RegistryPolicies Test {
	GPupdateInterval = 30
	Values = @(
		@{
			Key = "Software\Policies\Microsoft\Internet Explorer\Main\FeatureControl\Feature_zone_elevation"
			ValueName = '(Reserved)'
			TargetType = 'ComputerConfiguration'
			ValueData = '1'
			ValueType = 'String'
			Ensure = 'Present'
		},
		@{
			Key = "Software\Policies\Microsoft\Internet Explorer\Main\FeatureControl\Feature_zone_elevation"
			ValueName = 'explorer.exe'
			TargetType = 'ComputerConfiguration'
			ValueData = '1'
			ValueType = 'String'
			Ensure = 'Present'
		}
	)

Suggested solution

Update the replace regex in the resource:

$executionName = "$($value.Key)\$($value.ValueName)" -replace "[\s\\:*-+/{}```"']", '_'

From :

$executionName = "$($value.Key)\$($value.ValueName)" -replace "[\s\\:*-+/{}```"']", '_'

To

$executionName = "$($value.Key)\$($value.ValueName)" -replace "[\s()\\:*-+/{}```"']", '_'

Operating system the target node is running

OsName               : Microsoft Windows 10 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : fr-FR
OsMuiLanguages       : {fr-FR, en-US}

PowerShell version and build the target node is running

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

CommonTasks version

0.7.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions