首页 > 代码库 > DNS添加A记录

DNS添加A记录

#查询DNS可用类

Get-WmiObject -Namespace root\MicrosoftDNS -List

 

#查询所有资源记录

$rec = [WmiClass]\\server02\root\MicrosoftDNS:MicrosoftDNS_ResourceRecord$rec = [WmiClass]\\server02\root\MicrosoftDNS:MicrosoftDNS_ResourceRecord

 

#查询已有区域

gwmi -Namespace root\microsoftdns -Class MicrosoftDNS_zone |select ContainerName

 

#查询 ddv.com区域下的A记录

Get-WmiObject -Namespace root\MicrosoftDNS -class microsoftdns_atype | ? {$_.ContainerName -eq "ddv.com"} |Select TextRepresentation

 

#查询转发服务器

gwmi -Namespace "root\MicrosoftDNS" -class "MicrosoftDNS_Server" | Select-Object -ExpandProperty Forwarders

 

#批量添加A记录

$dnsServerName=""$containerName="ddv.com"$dns = [WMIClass]"ROOT\MicrosoftDNS:MicrosoftDNS_ResourceRecord"Get-Content D:\dnsListFile.txt | Foreach-Object {$dns.CreateInstanceFromTextRepresentation($dnsServerName, $containerName, $_)}

 dnsListFile.txt内容如下:
 aaa.ddv.com IN A 127.0.0.1
 bb.ddv.com IN A 127.0.0.2


From:http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/13/manage-dns-in-a-windows-environment-by-using-powershell.aspx

DNS添加A记录