DnsServerDsc icon indicating copy to clipboard operation
DnsServerDsc copied to clipboard

DnsRecordCname doesn't find record when target ends with '.'

Open XabiBeltza opened this issue 3 years ago • 1 comments

Problem description

When putting a full FQDN value on property HostNameAlias, the Test function is not able to find an existing record.

Verbose logs

"[OBFUSCATED]:                            [[DnsRecordCname]DirectResourceAccess] A matching DNS resource record not found.",
"[OBFUSCATED]:                            [[DnsRecordCname]DirectResourceAccess] DNS record property 'Ensure' is not correct. Expected 'Present', actual 'Absent'.",
"[OBFUSCATED]:                            [[DnsRecordCname]DirectResourceAccess] DNS record is NOT in the desired state.",
"[OBFUSCATED]: LCM:  [ End    Test     ]  [[DnsRecordCname]DirectResourceAccess] False in 4.7190 seconds."

DSC configuration

DnsRecordCname 'alias'
        {
            Name   = 'alias'
            HostNameAlias = 'desiredfqdn.zonename.com.'
            ZoneName = 'zonename.local'
            Ensure = 'Present'
            DnsServer = 'obfuscated.zonename.local'
        }

Suggested solution

I think the issue is in line 57 of source/Classes/002.DnsRecordCname.ps1. The filter adds a '.' to the property HostNameAlias: $_.RecordData.HostNameAlias -eq "$($this.HostnameAlias). This makes the filter skip the good record. The solution could be: determining first if the variable 'HostNameAlias' already is a proper FQDN with a dot in the end.

Operating system the target node is running

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

PowerShell version and build the target node is running

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

DnsServerDsc version

Name         Version Path
----         ------- ----
DnsServerDsc 3.0.0   C:\Program Files\WindowsPowerShell\Modules\DnsServerDsc\3.0.0\DnsServerDsc.psd1

XabiBeltza avatar Jun 28 '21 06:06 XabiBeltza

Thanks for reporting this! Happy to review a PR that solves this.

johlju avatar Jun 29 '21 15:06 johlju