Skip to content

xDnsRecord

Johan Ljunggren edited this page Jul 9, 2021 · 4 revisions

xDnsRecord

⚠️ DEPRECATED! The resource has been replaced by DnsServerA, DnsServerPtr, and DnsServerCName in the DSC resource module DnsServerDsc.

Parameters

Parameter Attribute DataType Description Allowed Values
Name Key String Specifies the name of the DNS server resource record object.
Zone Key String Specifies the name of a DNS zone.
Type Required String Specifies the type of DNS record. ARecord, CName, Ptr
Target Key String Specifies the Target Hostname or IP Address. Only Supports IPv4 in the current release.
DnsServer Write String Name of the DnsServer to create the record on. Defaults to 'localhost'.
Ensure Write String Should this DNS resource record be present or absent Present, Absent

Description

The xDnsRecord DSC resource manages IPv4 host (A), CName, or PTR DNS records against a specific zone on a Domian Name System (DNS) server.

Examples

Example 1

This configuration will manage a DNS A record

Configuration xDnsRecord_ARecord_config
{
    Import-DscResource -ModuleName 'xDnsServer'

    Node localhost
    {
        xDnsRecord 'TestRecord'
        {
            Name   = 'testArecord'
            Target = '192.168.0.123'
            Zone   = 'contoso.com'
            Type   = 'ARecord'
            Ensure = 'Present'
        }
    }
}

Example 2

This configuration will manage a pair of round-robin DNS A records

Configuration xDnsRecord_RoundRobin_config
{
    Import-DscResource -ModuleName 'xDnsServer'

    Node localhost
    {
        xDnsRecord 'TestRecord1'
        {
            Name   = 'testArecord'
            Target = '192.168.0.123'
            Zone   = 'contoso.com'
            Type   = 'ARecord'
            Ensure = 'Present'
        }

        xDnsRecord 'TestRecord2'
        {
            Name   = 'testArecord'
            Target = '192.168.0.124'
            Zone   = 'contoso.com'
            Type   = 'ARecord'
            Ensure = 'Present'
        }
    }
}

Example 3

This configuration will manage a DNS CName record

Configuration xDnsRecord_CName_config
{
    Import-DscResource -ModuleName 'xDnsServer'

    Node localhost
    {
        xDnsRecord 'TestCNameRecord'
        {
            Name   = 'testCName'
            Target = 'test.contoso.com'
            Zone   = 'contoso.com'
            Type   = 'CName'
            Ensure = 'Present'
        }
    }
}

Example 4

This configuration will manage a DNS PTR record

Configuration xDnsRecord_PTR_config
{
    Import-DscResource -ModuleName 'xDnsServer'

    Node localhost
    {
        xDnsRecord 'TestPtrRecord'
        {
            Name   = '123'
            Target = 'TestA.contoso.com'
            Zone   = '0.168.192.in-addr.arpa'
            Type   = 'PTR'
            Ensure = 'Present'
        }
    }
}

Example 5

This configuration will remove a DNS A record

Configuration xDnsRecord_ARecordRemove_config
{
    Import-DscResource -ModuleName 'xDnsServer'

    Node localhost
    {
        xDnsRecord 'RemoveTestRecord'
        {
            Name   = 'testArecord'
            Target = '192.168.0.123'
            Zone   = 'contoso.com'
            Type   = 'ARecord'
            Ensure = 'Absent'
        }
    }
}
Clone this wiki locally