Skip to content

DnsRecordTxt

dscbot edited this page Dec 5, 2025 · 1 revision

Parameters

Parameter Attribute DataType Description Allowed Values
DescriptiveText Key System.String Specifies additional text to describe a resource record on a DNS server. It is limited to 254 characters per line.
Name Key System.String Specifies the name of a DNS server resource record object.
ZoneName Key System.String Specifies the name of a DNS zone. (Key Parameter)
DnsServer Write System.String The host name of the Domain Name System (DNS) server, or use 'localhost' for the current node. Defaults to 'localhost'.
Ensure Write Ensure Whether the host record should be present or removed. Present, Absent
TimeToLive Write System.String Specifies the TimeToLive value of the SRV record. Value must be in valid TimeSpan string format (i.e.: Days.Hours:Minutes:Seconds.Miliseconds or 30.23:59:59.999).

Description

The DnsRecordTxt DSC resource manages TXT DNS records against a specific zone on a Domain Name System (DNS) server.

Examples

Example 1

This configuration will ensure a DNS TXT record exists when only the mandatory properties are specified.

Configuration DnsRecordTxt_Mandatory_config
{
    Import-DscResource -ModuleName 'DnsServerDsc'

    Node localhost
    {
        DnsRecordTxt 'TestRecord'
        {
            ZoneName        = 'contoso.com'
            Name            = 'test'
            DescriptiveText = 'Example text for test.contoso.com TXT record.'
            Ensure          = 'Present'
        }
    }
}

Example 2

This configuration will ensure a DNS TXT record exists when all properties are specified.

Configuration DnsRecordTxt_Full_config
{
    Import-DscResource -ModuleName 'DnsServerDsc'

    Node localhost
    {
        DnsRecordTxt 'TestRecord Multiline Full'
        {
            ZoneName        = 'contoso.com'
            Name            = 'sea2048._domainkey'
            DescriptiveText = 'Example text for test.contoso.com TXT record.'
            TimeToLive      = '01:00:00'
            DnsServer       = 'localhost'
            Ensure          = 'Present'
        }
    }
}

Example 3

This configuration will ensure a DNS TXT record does not exist when mandatory properties are specified.

Note that not all mandatory properties are necessarily key properties. Non-key property values will be ignored when determining whether the record is to be removed.

Configuration DnsRecordTxt_Remove_config
{
    Import-DscResource -ModuleName 'DnsServerDsc'

    Node localhost
    {
        DnsRecordTxt 'TestRecord'
        {
            ZoneName        = 'contoso.com'
            Name            = 'test'
            DescriptiveText = 'Example text for test.contoso.com TXT record.'
            Ensure          = 'Absent'
        }
    }
}

Clone this wiki locally