zoukankan      html  css  js  c++  java
  • DNS添加/修改/查询/删除A记录

    #查询DNS可用类

    Get-WmiObject -Namespace rootMicrosoftDNS -List

    #查询所有资源记录

    $mydns = [WMIClass]"ROOTMicrosoftDNS:MicrosoftDNS_ResourceRecord"
    $mydns = [WMIClass]"\$ServerROOTMicrosoftDNS:MicrosoftDNS_ResourceRecord"

    #查询已有区域

    gwmi -Namespace rootmicrosoftdns -Class MicrosoftDNS_zone |select ContainerName

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

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

    #查询单条A记录

    #查询 bb.ddv.com 的A记录
    $ARecord = Get-WmiObject -Namespace rootMicrosoftDNS -class MicrosoftDNS_ResourceRecord -filter "containername='ddv.com' AND OwnerName='bb.ddv.com'"
    #查询 bb.ddv.com 的A记录
    $ARecord = Get-WmiObject -Namespace rootMicrosoftDNS -class microsoftdns_atype | ? {$_.OwnerName -eq "bb.ddv.com"}

    #修改A记录

    #修改A记录 bb.ddv.com 的IP指向为172.0.0.23
    $ARecord = Get-WmiObject -Namespace rootMicrosoftDNS -class microsoftdns_atype | ? {$_.OwnerName -eq "bb.ddv.com"} 
    $ARecord.Modify($ARecord.TTL,"127.0.0.223")

     #删除A记录

    #删除A记录 bb.ddv.com 
    $ARecord = Get-WmiObject -Namespace rootMicrosoftDNS -class microsoftdns_atype | ? {$_.OwnerName -eq "bb.ddv.com"}
    $ARecord.delete()

    #添加A记录

    #添加单条A记录 bb.ddv.com IN A 127.0.0.3
    $dnsServerName=""
    $containerName="ddv.com"
    $dns = [WMIClass]"ROOTMicrosoftDNS:MicrosoftDNS_ResourceRecord"
    $dns.CreateInstanceFromTextRepresentation($dnsServerName, $containerName, "bb.ddv.com IN A 127.0.0.3")
    #批量添加A记录
    $dnsServerName=""
    $containerName="ddv.com"
    $dns = [WMIClass]"ROOTMicrosoftDNS: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

    #查询转发服务器

    gwmi -Namespace "rootMicrosoftDNS" -class "MicrosoftDNS_Server" | Select-Object -ExpandProperty Forwarders


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

  • 相关阅读:
    C#在winform上实现关于treeview与listview结合项目应用
    C#自学总结_Day2
    Base64 替换 BASE64Encoder
    MySql添加用户
    C#多线程服务,控制最大线程并发和最小线程并发
    C#/.net 移除URL上指定的参数,不区分参数大小写
    C#.NET根据数据库中0,1返回对应代表含义“男”,“女”等问题
    d3 学习记录-----network实现
    c#判断串口是否断开,并自动重连
    winform Anchor和Dock属性
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/4022651.html
Copyright © 2011-2022 走看看