#author:xiaoping.qiu
#date:20180810
#dns server name
$servername = "dcname"
#domain name
$domain = "domain.com"
#dnscreate.csv
#
# |computer | ip |
# | linuxsrv45 | 192.168.127.45 |
$dns_list = Import-Csv D:\dnscreate.csv
$dns_list | %{
$computer = "$($_.computer).$domain"
$addr = $_.ip -split "\."
$rzone = "$($addr[2]).$($addr[1]).$($addr[0]).in-addr.arpa"
dnscmd $servername /recordadd $domain "$($_.computer)" A "$($_.ip)"
dnscmd $servername /zoneadd $rzone /primary
dnscmd $servername /recordadd $rzone "$($addr[3])" PTR $computer
}
powershell 批量添加dns记录
在系统运维实践中经常有大量添加dns记录的需求,如果手动添加,那就非常耗时而且容易出错。Windows powershell对这一块支持的特别好,我参考一些技术文档写了如下脚本,使用起来非常方便。供大家参考: