Usage of Set-DNSServerSetting

Hello all togehter,

I have severall Windows 2012 DCs with DNS installed. Until now, I use a batch file to configure the DNS for my demands. Since 2012, I can configure DNS with PowerShell and I want to fully migrate the cmd commands to PowerShell. Basically this should work, but I do not fully understand how the Set-DNSServerSetting cmdlet works.

For example, I want to change the setting for "LocalNetPriority" and "RoundRobin".

If I use Get-DNServerSetting -All, PowerShell displays me the current values for these settings (true or false). And as the cmdlet help shows in the example, I can use "Get-DNSServerSetting -All -Computername Server007 | Set-DNSServerSetting" to copy the settings from an existing server.

However, I don't want to copy the settings, but just write the settings as I defined, like "$MySettings | Set-DNSServerSetting", where $MySettings contains the Object with all settings I need. But how can I create such an object in my script, without copying the settings from another DNS server?

To be more clear: I wish the Set-DNSServerSetting cmdlet would work like "Set-DNSServerSetting -RoundRobin $true -LocalNetPriority $true", but it doesn't. Who has a workaround for me?

Thanks,
Michael

PS: I know, dnscmd would also work in my PowerShell script, but I try to use PowerShell cmdlets.

January 24th, 2014 3:51pm

Hi,

Based on my research, the command accept CimInstance (DnsServerSetting) as input.

The input type is the type of the objects that you can pipe to the cmdlet.

  • "Class: DNSServerSettings {

    string  Name; //Specifies the FQDN or IP address of a DNS server. This specification should be common across roles.

    uint32  Version;  //Specifies the read-only version of the DNS server.

    sint32  RpcProtocol; //Specifies the remote procedure call (RPC) protocol or protocols over which administrative RPC runs.

    uint32 NameCheckFlag; //Specifies the set of eligible characters to use in DNS server names.

    uint32  AddressAnswerLimit; //Specifies the maximum number of host records that are returned in response to an address request. Values of 5 through 28 are valid.

    uint32  BootMethod; //Specifies the initialization method for a DNS server.

    boolean DsAvailable; //Indicates whether an available directory service is on the DNS server.

    boolean DisableAutoReverseZones; //Indicates whether the DNS server automatically creates standard reverse lookup zones.

    boolean RoundRobin; //Indicates whether the DNS server uses the round robin mechanism to rotate the order of multiple address (A) records.

    boolean LooseWildcarding ;//Indicates whether the DNS server uses loose wildcards. If undefined or zero, the server follows the wildcard behavior that is specified in the DNS RFC. In this case, an administrator should include mail exchanger (MX) records for all hosts that cannot receive mail. If nonzero, the server seeks the closest wildcard node and an administrator should put MX records at the zone root and in a wildcard node (*) directly below the zone root. Administrators should also put self-referencing MX records on hosts that receive their own mail.

    boolean WriteAuthorityNS; //Indicates whether the DNS server writes name server (NS) and start of authority (SOA) records to the authority section on successful response.

More about DnsServerSetting class: http://msdn.microsoft.com/en-us/library/dn441287(v=vs.85).aspx

It will be easy if we just copy settings from another DNS server.

Regards,

Yan Li

Free Windows Admin Tool Kit Click here and download it now
January 27th, 2014 2:27am

Hi Yan Li,

exactly, it would be easy to copy settings from another DNS sever, but I won't. :)

Of course I know the cmdlet help page, but as I said, i don't realy understand how to do it, if i don't want do copy the setting from another DNS server.

Anyone else?

Regards,
Michael

January 27th, 2014 6:32am

Hi,

Please review the article as below:

Use PowerShell to Configure Static IP and DNS Settings

http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/28/use-powershell-to-configure-static-ip-and-dns-settings.aspx

Moreover, I notice that you would like to customize the Set-DNSServerSetting:

Server - WMI sample in Powershell

http://www.activexperts.com/admin/scripts/wmiscripts/powershell/1454/

Best regards,

Steven Song

Free Windows Admin Tool Kit Click here and download it now
February 4th, 2014 9:00am

Hi Steven,

the first article is about DNS client settings, not DNS server or the Set-DnsServerSettings cmdlet.

For the moment I did a workaround with configureing the settings directly in the registry with PowerShell. So, it's working but not as nice as I wish it would be. :)

However, the question is still open. How can I configure a DNS server with Set-DnsServerSetting _without piping the settings from another DNS server_.

Regards,
Michael

February 7th, 2014 12:54pm

Been trying to work out this for a few hours ....

Using the XML export / import cmdlet you can save the settings of a dns server into an XML file, you can also reverse the process taking an xml file and applying settings.

You could obviously export the xml file from your server parse /update the settings within the xml and adjust a particular setting based on the server configuration.

Get-DnsServerSetting-computername127.0.0.1-all | Export-Clixml  c:\input\test.xml

$a =Import-Clixml  c:\input\test.xml
 
Set-DnsServerSetting-computername127.0.0.1 $a

I'll be working on a PS script which will alter the DNS server bindings to make sure that we only bind to the primary Nic.

Let me know if your interested.


Rgds

Martin




Free Windows Admin Tool Kit Click here and download it now
April 15th, 2015 6:46pm

Been trying to work out this for a few hours ....

Using the XML export / import cmdlet you can save the settings of a dns server into an XML file, you can also reverse the process taking an xml file and applying settings.

You could obviously export the xml file from your server parse /update the settings within the xml and adjust a particular setting based on the server configuration.

Get-DnsServerSetting-computername127.0.0.1-all | Export-Clixml  c:\input\test.xml

$a =Import-Clixml  c:\input\test.xml
 
Set-DnsServerSetting-computername127.0.0.1 $a

I'll be working on a PS script which will alter the DNS server bindings to make sure that we only bind to the primary Nic.

Let me know if your interested.


Rgds

Martin




April 15th, 2015 10:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics