Skip to content

DnsRecordCnameScoped

dscbot edited this page Apr 12, 2025 · 4 revisions

Parameters

Parameter Attribute DataType Description Allowed Values
HostNameAlias Key System.String Specifies a a canonical name target for a CNAME record. This must be a fully qualified domain name (FQDN). (Key Parameter)
Name Key System.String Specifies the name of a DNS server resource record object. (Key Parameter)
ZoneName Key System.String Specifies the name of a DNS zone. (Key Parameter)
ZoneScope Key System.String Specifies the name of a zone scope. (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 DnsRecordCnameScoped DSC resource manages CNAME DNS records against a specific zone and zone scope on a Domain Name System (DNS) server.

Examples

Example 1

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

Configuration DnsRecordCnameScoped_Mandatory_config
{
    Import-DscResource -ModuleName 'DnsServerDsc'

    Node localhost
    {
        DnsRecordCnameScoped 'TestRecord'
        {
            ZoneName      = 'contoso.com'
            ZoneScope     = 'external'
            Name          = 'bar'
            HostNameAlias = 'quarks.contoso.com'
            Ensure        = 'Present'
        }
    }
}

Example 2

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

Configuration DnsRecordCnameScoped_Full_config
{
    Import-DscResource -ModuleName 'DnsServerDsc'

    Node localhost
    {
        DnsRecordCnameScoped 'TestRecord'
        {
            ZoneName      = 'contoso.com'
            ZoneScope     = 'external'
            Name          = 'bar'
            HostNameAlias = 'quarks.contoso.com'
            TimeToLive    = '01:00:00'
            DnsServer     = 'localhost'
            Ensure        = 'Present'
        }
    }
}

Example 3

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

Configuration DnsRecordCnameScoped_Remove_config
{
    Import-DscResource -ModuleName 'DnsServerDsc'

    Node localhost
    {
        DnsRecordCnameScoped 'TestRecord'
        {
            ZoneName      = 'contoso.com'
            ZoneScope     = 'external'
            Name          = 'bar'
            HostNameAlias = 'quarks.contoso.com'
            Ensure        = 'Absent'
        }
    }
}

Clone this wiki locally