1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix special case for '(default)' entries in original module

This commit is contained in:
Dag Wieers 2017-01-25 12:51:42 +01:00
parent cfb7b12f82
commit 454dde5dfd

View file

@ -150,10 +150,12 @@ if ($type -eq "binary" -and $data -ne $null -and $data -is [String]) {
$data = Convert-RegExportHexStringToByteArray($data)
}
# Expand string if type expandstring
if ($type -eq "expandstring" -and $data -ne $null -and $data -is [String]) {
$data = Expand-Environment($data)
$datatype = "string"
# Special case handling for the path's default property.
if ($name.ToLower() -eq "(default)") {
if ($type -eq "expandstring" -and $data -ne $null -and $data -is [String]) {
$data = Expand-Environment($data)
}
$type = "string"
}
if ($state -eq "present") {
@ -177,8 +179,12 @@ if ($state -eq "present") {
# Changes Data and DataType
if (-not $check_mode) {
try {
Remove-ItemProperty -Path $path -Name $name
New-ItemProperty -Path $path -Name $name -Value $data -PropertyType $type -Force
if ($name.ToLower() -eq "(default)") {
$null = $(Get-Item -Path $path -ErrorAction 'Stop').OpenSubKey('','ReadWriteSubTree').SetValue($null,$data)
} else {
Remove-ItemProperty -Path $path -Name $name
New-ItemProperty -Path $path -Name $name -Value $data -PropertyType $type -Force
}
} catch {
Fail-Json $result $_.Exception.Message
}