diff --git a/lib/ansible/modules/extras/windows/win_regedit.ps1 b/lib/ansible/modules/extras/windows/win_regedit.ps1 index f9491e39c57..e3b8c9d3b10 100644 --- a/lib/ansible/modules/extras/windows/win_regedit.ps1 +++ b/lib/ansible/modules/extras/windows/win_regedit.ps1 @@ -57,8 +57,16 @@ if($state -eq "present") { { if (Test-RegistryValueData -Path $registryKey -Value $registryValue) { + if ($registryValue.ToLower() -eq "(default)") { + # Special case handling for the key's default property. Because .GetValueKind() doesn't work for the (default) key property + $oldRegistryDataType = "String" + } + else { + $oldRegistryDataType = (Get-Item $registryKey).GetValueKind($registryValue) + } + # Changes Data and DataType - if ((Get-Item $registryKey).GetValueKind($registryValue) -ne $registryDataType) + if ($registryDataType -ne $oldRegistryDataType) { Try {