PowerShell Script to work with DNS WMI Provider
The DNS WMI provider exposes a number of DNS objects, including DNS Servers, DNS domains, DNS Zones and DNS Resource Records etc. We could use these objects to manage DNS and you guess it, through PowerShell!
The DNS WMI Provider is installed on Windows Server 2003 by default. For Windows 2000, you could obtain the DNS WMI Provider from Windows 2000 Server Resource Kit or follow this Link
Here is a PowerShell script to list DNS Zones
Get-WmiObject -namespace "root\MicrosoftDNS" -class MicrosoftDNS_Zone -Credential DnsServer\Administrator -ComputerName DnsServer
This will list all the DNS zones on your DNS server(Microsoft DNS server, that is)!
If you want to see what other classes are there
Get-WmiObject -namespace "root\MicrosoftDNS" -Credential DnsServer\Admin
istrator -ComputerName DnsServer -list
__SystemClass __NAMESPACE
__Provider __Win32Provider
__ProviderRegistration __ObjectProviderRegistration
__ClassProviderRegistration __InstanceProviderRegistration
__PropertyProviderRegistration __MethodProviderRegistration
__EventProviderRegistration __EventConsumerProviderRegistration
__NotifyStatus __ExtendedStatus
__CIMOMIdentification __SecurityRelatedClass
__NTLMUser9X __IndicationRelated
__Event __PARAMETERS
__ExtrinsicEvent __NamespaceOperationEvent
__NamespaceCreationEvent __NamespaceDeletionEvent
__NamespaceModificationEvent __ClassOperationEvent
__ClassCreationEvent __ClassDeletionEvent
__ClassModificationEvent __InstanceOperationEvent
__InstanceCreationEvent __InstanceDeletionEvent
__InstanceModificationEvent __TimerEvent
__AggregateEvent __EventConsumer
__EventFilter __FilterToConsumerBinding
__EventGenerator __TimerInstruction
__AbsoluteTimerInstruction __IntervalTimerInstruction
__TimerNextFiring __SystemEvent
__EventDroppedEvent __EventQueueOverflowEvent
__ConsumerFailureEvent __SystemSecurity
CIM_ManagedSystemElement CIM_LogicalElement
CIM_Service MicrosoftDNS_Server
MicrosoftDNS_Domain MicrosoftDNS_Zone
MicrosoftDNS_Cache MicrosoftDNS_RootHints
MicrosoftDNS_ResourceRecord MicrosoftDNS_AType
MicrosoftDNS_SOAType MicrosoftDNS_PTRType
MicrosoftDNS_NSType MicrosoftDNS_CNAMEType
MicrosoftDNS_MBType MicrosoftDNS_MDType
MicrosoftDNS_MFType MicrosoftDNS_MGType
MicrosoftDNS_MRType MicrosoftDNS_MINFOType
MicrosoftDNS_RPType MicrosoftDNS_MXType
MicrosoftDNS_AFSDBType MicrosoftDNS_RTType
MicrosoftDNS_HINFOType MicrosoftDNS_ISDNType
MicrosoftDNS_TXTType MicrosoftDNS_X25Type
MicrosoftDNS_WKSType MicrosoftDNS_AAAAType
MicrosoftDNS_SRVType MicrosoftDNS_ATMAType
MicrosoftDNS_WINSType MicrosoftDNS_WINSRType
CIM_Component MicrosoftDNS_ServerDomainContainment
MicrosoftDNS_DomainDomainContainment MicrosoftDNS_DomainResourceRecordContainment
from here, you could replace MicrosoftDNS_Zone class with MicrosoftDNS_ResourceRecord class etc.
Have fun!