Query and retrieve all A records of a specific DNS zone
Script :
$dns_entries = Get-WmiObject -namespace "root\MicrosoftDNS" -class MicrosoftDNS_Atype -ComputerName dnsServerName -Filter "DomainName = 'domain.local.net'" foreach ($dnsrecord in $dns_entries) { $dnsrecord.IPAddress + "`t" + $dnsrecord.OwnerName.split(".")[0] + "`t" + $dnsrecord.OwnerName }
Reference
WMI Discovery using PowerShell
Get-WmiObject
Gets instances of Windows Management Instrumentation (WMI) classes or information about the available classes.
Syntax
Parameter Set: query
Get-WmiObject [-Class] [[-Property] <String[]> ] [-Amended] [-AsJob] [-Authentication ] [-Authority ] [-ComputerName <String[]> ] [-Credential ] [-DirectRead] [-EnableAllPrivileges] [-Filter ] [-Impersonation ] [-Locale ] [-Namespace ] [-ThrottleLimit ] [ ]
Parameter Set: class
Get-WmiObject [-Amended] [-AsJob] [-Authentication ] [-Authority ] [-ComputerName <String[]> ] [-Credential ] [-EnableAllPrivileges] [-Impersonation ] [-Locale ] [-Namespace ] [-ThrottleLimit ] [ ]
Parameter Set: list
Get-WmiObject [[-Class] ] [-Amended] [-AsJob] [-Authentication ] [-Authority ] [-ComputerName <String[]> ] [-Credential ] [-EnableAllPrivileges] [-Impersonation ] [-List] [-Locale ] [-Namespace ] [-Recurse] [-ThrottleLimit ] [ ]
Parameter Set: path
Get-WmiObject [-Amended] [-AsJob] [-Authentication ] [-Authority ] [-ComputerName <String[]> ] [-Credential ] [-EnableAllPrivileges] [-Impersonation ] [-Locale ] [-Namespace ] [-ThrottleLimit ] [ ]
Parameter Set: WQLQuery
Get-WmiObject -Query [-Amended] [-AsJob] [-Authentication ] [-Authority ] [-ComputerName <String[]> ] [-Credential ] [-DirectRead] [-EnableAllPrivileges] [-Impersonation ] [-Locale ] [-Namespace ] [-ThrottleLimit ] [ ]
Detailed Description
The Get-WmiObject cmdlet gets instances of WMI classes or information about the available WMI classes. To specify a remote computer, use the ComputerName parameter. If the List parameter is specified, the cmdlet gets information about the WMI classes that are available in a specified namespace. If the Query parameter is specified, the cmdlet runs a WMI query language (WQL) statement.
The Get-WmiObject cmdlet does not use Windows PowerShell remoting to perform remote operations. You can use the ComputerName parameter of the Get-WmiObject cmdlet even if your computer does not meet the requirements for Windows PowerShell remoting or is not configured for remoting in Windows PowerShell.
Beginning in Windows PowerShell 3.0, the __Server property of the object that Get-WmiObject returns has a PSComputerName alias. This makes it easier to include the source computer name in output and reports.
DNS WMI Classes
The following table lists and describes the WMI classes that are associated with the DNS Server service.
Microsoft DNS WMI Class | Description |
---|---|
MicrosoftDNS_Server | Describes a DNS server. Every instance of this class might be associated with one instance of class MicrosoftDNS_Cache, one instance of class MicrosoftDNS_RootHints, and multiple instances of class MicrosoftDNS_Zone. |
MicrosoftDNS_Domain | Represents a domain in a DNS hierarchy tree. |
MicrosoftDNS_Zone | Describes a DNS zone. Every instance of the class MicrosoftDNS_Zone must be assigned to exactly one DNS server. Zones might be associated with multiple instances of the classes MicrosoftDNS_Domain and MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_Cache | Describes a cache existing on a DNS server. (Do not confuse this with a cache file that contains root hints.) This class simplifies visualizing the containment of DNS objects, rather than representing a real object. The class is a container for the resource records cached by the DNS server.Every instance of the class MicrosoftDNS_Cache must be assigned to exactly one DNS server. It might be associated with multiple instances of MicrosoftDNS_Domain and MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_RootHints | Describes the RootHints stored in a cache file on a DNS server. This class simplifies visualizing the containment of DNS objects, rather than representing a real object. The class is a container for the resource records stored by the DNS server in a cache file.Every instance of the class MicrosoftDNS_RootHints must be assigned to exactly one DNS server. It might be associated with multiple instances of the MicrosoftDNS_ResourceRecord class. |
MicrosoftDNS_Statistic | Represents a single DNS server statistic. |
MicrosoftDNS_ServerDomainContainment | Every instance of the class MicrosoftDNS_ServerDomainContainment might contain multiple instances of the class MicrosoftDNS_Domain. |
MicrosoftDNS_DomainDomainContainment | Every instance of the MicrosoftDNS_DomainDomainContainment class might contain multiple other instances of MicrosoftDNS_Domain. |
MicrosoftDNS_DomainResourceRecordContainment | Every instance of the class MicrosoftDNS_DomainResourceRecordComtainment might contain multiple instances of the MicrosoftDNS_ResourceRecord class. |
MicrosoftDNS_ResourceRecord | Represents the general properties of a DNS resource record (RR). |
MicrosoftDNS_AAAAType | Represents an IPv6 Address (AAAA), often pronounced quad-A, RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_AFSDBType | Represents an Andrew File System Database Server (AFSDB) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_ATMAType | Represents an ATM Address-to-Name (ATMA) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_AType | Represents an Address (A) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_CNAMEType | Represents a Canonical Name (CNAME) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_HINFOType | Represents a Host Information (HINFO) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_ISDNType | Represents an ISDN RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_KEYType | Represents a KEY RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_MBType | Represents a Mailbox (MB) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_MDType | Represents a Mail Agent for Domain (MD) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_MFType | Represents a Mail Forwarding Agent for Domain (MF) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_MGType | Represents an MG RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_MINFOType | Represents a Mail Information (MINFO) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_MRType | Represents a Mailbox Rename (MR) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_MXType | Represents a Mail Exchanger (MX) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_NSType | Represents a Name Server (NS) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_NXTType | Represents a Next (NXT) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_PTRType | Represents a Pointer (PTR) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_RPType | Represents a Responsible Person (RP) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_RTType | Represents a Route Through (RT) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_SIGType | Represents a Signature (SIG) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_SOAType | Represents a Start Of Authority (SOA) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_SRVType | Represents a Service (SRV) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_TXTType | Represents a Text (TXT) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_WINSRType | Represents a WINS-Reverse (WINSR) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_WINSType | Represents a WINS RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_WKSType | Represents a Well-Known Service (WKS) RR. Subclass of MicrosoftDNS_ResourceRecord. |
MicrosoftDNS_X25Type | Represents an X.25 (X25) RR. Subclass of MicrosoftDNS_ResourceRecord. |