none
DNS / Powershell Script Question RRS feed

  • Question

  • I am trying to use the following Powershell code to bulk import DNS A records into Windows 2008 DNS:
    Import-Csv .\thosts.csv | foreach{Add-DnsServerResourceRecordA -Name $_.name -ZoneName xxxxx.com -AllowUpdateAny -CreatePtr -IP $_.ip -

    Computername xxxxxxx} 

    My CSV file looks like this:
    Name, IP
    ABQVMP01, 130.77.129.237

    It runs successfully, but the DNS name ends up being ABQVMP01.xxxxx.com.xxxxx.com, instead of ABQVMP01.xxxxx.com. I have looked for something 

    to control this in the command syntax, but do not see anything: https://docs.microsoft.com/en-us/powershell/module/dnsserver/add-

    dnsserverresourcerecorda?view=win10-ps

    We are running AD and DNS at the 2008 level. Powershell is version 5.1. I am running this as a domain admin.

    Thanks in advance and happy to answer any more questions,
    Rick
    Wednesday, January 16, 2019 5:06 AM

Answers

  • Hi Lee,

    Thanks for your response. I swapped the command to use -IPV4Address vs. -IP and got records to create in the primary zone.

    Cheers,

    Rick

    • Marked as answer by RickV123 Wednesday, January 16, 2019 6:46 PM
    Wednesday, January 16, 2019 6:41 PM

All replies

  • Greetings,

    I am trying to use the following Powershell code to bulk import DNS A records into Windows 2008 DNS:
    Import-Csv .\thosts.csv | foreach{Add-DnsServerResourceRecordA -Name $_.name -ZoneName xxxxx.com -AllowUpdateAny -CreatePtr -IP $_.ip 

    -Computername xxxxxxx} 

    My CSV file looks like this:
    Name, IP
    ABQVMP01, 130.77.129.237

    It runs successfully, but the DNS name ends up being ABQVMP01.xxxxx.com.xxxxx.com, instead of ABQVMP01.xxxxx.com. I have looked for something to control this in the command syntax, but do not see anything: https://docs.microsoft.com/en-us/powershell/module/dnsserver/add-dnsserverresourcerecorda?view=win10-ps

    We are running AD and DNS at the 2008 level. Powershell is version 5.1. I am running this as a domain admin.

    Thanks in advance and happy to answer any more questions,
    Rick
    Wednesday, January 16, 2019 4:15 AM
  • Hi,

    Thanks for your question.

    Maybe you need to check your CSV file. I don't think any wrong with your PowerShell script. Please refer the link below to add DNS a record from CSV file. 

    https://gallery.technet.microsoft.com/scriptcenter/Create-DNS-A-records-from-2d931ff8

    You also can get all the DNS a record by using the command below to check the DNS name.

    Get-DnsServerResourceRecord -ZoneName "contoso.com" -RRType "A"

    Best Regards,

    Lee


    Just do it.

    Wednesday, January 16, 2019 6:44 AM
  • Hello Rick!

    I think this is maybe more a question for the PowerShell forums, you could try asking there, I believe the experts there can help you out!

    Scripting  >  Windows PowerShell

    Best regards,
    Leon


    Blog: https://thesystemcenterblog.com LinkedIn:

    Wednesday, January 16, 2019 8:29 AM
  • Hi Lee,

    Thanks for your response. I swapped the command to use -IPV4Address vs. -IP and got records to create in the primary zone.

    Cheers,

    Rick

    • Marked as answer by RickV123 Wednesday, January 16, 2019 6:46 PM
    Wednesday, January 16, 2019 6:41 PM
  • Thanks Leon for your response

    Rick

    Wednesday, January 16, 2019 6:41 PM