Share This Post

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!

Share This Post

Ying Li obtained a Master degree of Medicine in China and worked in the medical field before he came to the states in 1996. He made the career switch from troubleshooting people to troubleshooting computers after he came to the states. Not entirely a surprise there, if you know that his second preference for college is Mathematics. Ying is two times Admin Framework MVP awardee (2007-2008).His previous employment experience in the US includes UUNET, MCI WorldCom. MMC (Marsh & McLennan Companies), Merrill Lynch. He is currently employed by Related Companies as a Senior Infrastructure Engineer. He is proficient in virtually all Microsoft products (Office/Back office). His craving for efficiency naturally leads him to scripting, automation and before you know it, PowerShell! He is currently a MCSE (NT4, 2000, 2003) and MCITP Server Administrator. Ying enjoys wines and love to travel. His non work related passion is to advocate Health Living!

Leave a Reply