none
Adding type A DNS records using a powershell script RRS feed

  • Question

  • Adding type A DNS records using the Add-DnsServerResourceRecordA cmdlet works but it cannot be used in an auto-running powershell script due to the lack of the -Force option. I've noticed that the generic version of the cmdlet, Add-DnsServerResourceRecord, accepts the -Force option but not when adding type A Dns records using the -IPv4Address option. Is  there a workaround for this behavior? Is there any reason on why Microsoft has chosen not to include the -Force option for the Add-DnsServerResourceRecordA cmdlet? Thanks.


    Monday, November 18, 2019 7:25 PM

Answers

  • I imagine the -Force was left off because you can do serious damage to your whole network, DNS, AD, etc. However, there have been examples for automating the creation of DNS records in the past. Here's one example:

    https://social.technet.microsoft.com/Forums/windows/en-US/2e0fe0ef-b0f6-4fa0-9980-6e354200c258/how-can-i-combine-adddnsserverresourcerecorda-amp-adddnsserverresourcerecordptr-cmdlets-to?forum=winserverpowershell

    You could also build a function to query the DNS services to check if a record already exists.

    If you would like to report issues with the cmdlet or gain more insight as to why -Force isn't available, you can do so here:

    https://github.com/PowerShell/PowerShell/issues

    Monday, November 18, 2019 8:02 PM