Windows PowerShell


PowerShell - Scripting DNS with WMI

PowerShell - Scripting DNS with WMI

Our mission on this page is to install the Root\MicrosoftDNS namespace.

WMI and PowerShell Topics

Get-WmiObject

How to Install Root\MicrosoftDNS

CIM means Common Information Model, with WMI, mostly we connect to Root\Cimv2.  However there are other CIM providers, for example Root\MicrosoftDNS.

The problem.  If we enumerate the CIM namespaces, we see that MicrosoftDNS is not listed BEFORE our procedure below.

CLS
$RootName = get-wmiobject -namespace "root" -class __NAMESPACE `
| Sort-Object "Name"
Foreach ($Provider in $RootName) {
$Provider.name |Out-File -filePath provider.txt -append

 Before

After Procedure Below

aspnet
CIMV2
Cli
DEFAULT
directory
Microsoft
MicrosoftActiveDirectory

MicrosoftIISv2
MicrosoftNLB
MSAPPS11
MSAPPS12
MSCluster
perfmon
Policy
RSOP
SECURITY
snmp
subscription
vm
WMI
aspnet
CIMV2
Cli
DEFAULT
directory
Microsoft
MicrosoftActiveDirectory
MicrosoftDNS
MicrosoftIISv2
MicrosoftNLB
MSAPPS11
MSAPPS12
MSCluster
perfmon
Policy
RSOP
SECURITY
snmp
subscription
vm
WMI

 

Windows Server 2003 appears to have the necessary files, dnsschema.mof and dnsprov.dll, it's just they are not registered by default.

Agony and Ecstasy of dnsprov download

The agony would be if you went ahead and copied the files in dnsprov.zip.  The problem is that these are Windows 2000 files and may not have a good effect on a Windows 2003 Server.

The ecstasy came when studying the readme file.  This file showed me that the files I needed were, dnsschema.mof and dnsprov.dll.  When I looked in the...\wbem folder I saw that the Windows Server 2003 version of the files were already there, thus all that I needed to do was to register them.

How To install the dns provider (You have to do this manually)

  • Check that dnsschema.mof and dnsprov.dll are in %windir%\system32\wbem.
  • This is how you register the class information from the Run box:
  • Click on Start, in the Run box type:
    "mofcomp dnsschema.mof"
  • This is how to register the .dll.  At the run box copy and paste:
    "regsvr32 dnsprov.dll"

Check the Properties for Root\MicrosoftDNS

Cls
$DNSRoot = get-wmiobject -namespace "root\MicrosoftDNS" -list
$DNSRoot

Note 1: You could substitute root\cimv2 for root\MicrosoftDNS

Guy Recommends: SolarWinds LANSurveyorSolarwinds LANSurveyor

LANSurveyor will produce a neat diagram of your network topology.  But that's just the start; LANSurveyor can create an inventory of the hardware and software of your machines and network devices.  Other neat features include dynamic update for when you add new devices to your network.  I also love the ability to export the diagrams to Microsoft Visio.

Finally, Guy bets that if you take a free trial of LANSurveyor then you will find a device on your network that you had forgotten about, or someone else installed without you realizing!

Download a Free Trial of LANSurveyor

Summary of reading files for PowerShell scripting

It is often useful to read hostnames from a text file, then persuade PowerShell to loop through a WMI class and finally, display the data in a table.

See more Microsoft PowerShell examples of WMI

PowerShell Home   • WMI   • Service   • WMI File   • WMI Query   • DNS   • Disk

Classes   • Network Adapter   • PowerShell WMI examples

Please write in if you see errors of any kind.  Please report any factual mistakes, grammatical errors or broken links, I will be happy to not only to correct the fault, but also to give you credit.

Download my ebook:Getting Started with PowerShell
Getting Started with PowerShell - only $9.25

You get 36 topics organized into these 3 sections:
   1) Getting Started
   2) Real-life tasks
   3) Examples of Syntax.

In addition to the ebook, you get a PDF version of this  Introduction to PowerShell ebook  It runs to 120 pages of A4.

 *


Google

Web  This website

Review of Orion NPMGuy Recommends: Orion's NPM - Network Performance Monitor

Orion's performance monitor is designed for detecting network outages. A network-centric view make it easy to see what's working, and what needs your attention.

This utility guides you through troubleshooting by indicating whether the root cause is faulty equipment or resource overload.

Download a free trial of the Network Performance Monitor

 

Home Copyright © 1999-2009 Computer Performance LTD All rights reserved

Please report a broken link, or an error.