PowerShell, Technology

Creating Bulk DNS Records with PowerShell

PowerShell is a great tool for managing your repetitive tasks with DNS records. In this example I will show you how you can bulk import DNS records to Windows DNS servers.

 

 

  1. Populate a CSV with your device names and IP’s
  2. In PowerShell, import your CSV with the devices and IPs:
    #Import CSV
    $devices = Import-Csv "\\ServerPath\devices.csv"

    3. Loop through the devices and create the DNS records

    foreach($device in $devices)
    {       
          #the following line creates the DNS record with the device name and IP from the imported CSV
          Add-DnsServerResourceRecordA -Name $device.name -ZoneName "yourdomain.com" -AllowUpdateAny -IPv4Address $device.ip -TimeToLive 01:00:00
    }

Leave a Reply

Your email address will not be published. Required fields are marked *