enumerating dns records with powershell

here's a way to list dns records with powershell going through wmi. keep in mind the dns class does not appear to support wildcards. :(

get-wmiobject -ComputerName servername -Namespace root\microsoftDNS -Class MicrosoftDNS_ResourceRecord -Filter "domainname='mydomain'" | select textrepresentation
 

i haven't figured out how to loop through subdomains and dump them out yet. :/ it's a start. hopefully you guys have something better you can share.

Comments

  1. Years (really) ago, I worked around the no-wildcard limitation by querying AD for DNSnode objects. For my particular problem (just wanted a IPs of hosts matching a simple wildcard pattern) and domain (without AD-integrated DNS this is useless, of course) it worked ok.

    #requires –PsSnapIn Quest.ActiveRoles.ADManagement
    #requires –PsSnapIn PSCX
    get-qadobject -name $args[0] -Type dnsnode | %{resolve-host $_.name}

    That's all there was to it. Nowadays instead of the Quest AD module you could use the native one, and PSCX probably has a modern follow up, too.

    ReplyDelete

Post a Comment