Bulk creating DNS records
Recently I needed to create tens of DNS records. This little script automates the creation of DNS records.
The scripts reads a csv file which contains the hostname and the according IP address. This information is used to launch dnscmd which creates the DNS records in the supplied DNS zone.
1
2$DnsServer = "localhost"
3$DnsZone = "test.demo"
4
5\# Load IP configuration csv file
6$HostIPinfo = Import-Csv -Path "C:\\Scripts\\HostIPinfo.csv"
7
8.
9\# Create DNS record for every hosts
10$HostIPinfo | ForEach-Object {
11 dnscmd $DnsServer /RecordAdd $DnsZone $_.Server /CreatePTR A $_.Management
12}
Csv file content
1Server,Management
2server01,192.168.0.1
3server02,192.168.0.2
4server03,192.168.0.3
5server04,192.168.0.4