Guy recommends :
Free Solarwinds
VM Console

Solarwinds VM Console Free Download

Find out which of your VMs are a waste of space and which VMs need more resources.



Scripting PowerShell DNS with WMI

PowerShell - Scripting DNS with WMI

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

 PowerShell WMI DNS Topics

 ♣

Preparation With PowerShell's Get-Help

Before we use PowerShell's DNS, let us investigate the master cmdlet Get-WmiObject.  In particular, we need to understand the syntax of parameters such as -Class and -ComputerName.  Incidentally, you can use the alias gwmi instead of of Get-WmiObject.

# Help with PowerShell WMI object:
Get-help Get-WmiObject

Note 1: If you prefer to see examples append -full, thus: help Get-WmiObject -full

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.

# PowerShell DNS Provider
Clear-Host
$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 appears to have the necessary files, dnsschema.mof and dnsprov.dll, it's just they are not registered by default.

Guy Recommends:  Solarwinds' Free Bulk Import ToolFree Download of Solarwinds  Bulk Import Tool

Import users from a spreadsheet.  Just provide a list of the users with their fields in the top row, and save as .csv file.  Then launch this FREE utility and match your fields with AD's attributes, click to import the users.  Optionally, you can provide the name of the OU where the new accounts will be born.

There are also two bonus tools in this free download, and all 3 have been approved by Microsoft:

  1. Bulk-import new users into Active Directory.
  2. Seek and zap unwanted user accounts.
  3. Find inactive computers.

Download your FREE bulk import tool.

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

# PowerShell DNS
Clear-Host
$DNSRoot = Get-WmiObject -namespace "root\MicrosoftDNS" -list
$DNSRoot | Where{$_.Name -notlike "__*"} | Format-Table Name, Property

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

 

PowerShell DNS Summary

To get started configuring DNS via PowerShell make sure that you install the MicrosoftDNS namespace. 

If you like this page then please share it with your friends

 


See More Microsoft PowerShell WMI Examples:

Home   • PowerShell Get-WmiObject   • WMI Services   • Win32_ComputerSystem

WMI Class  • [WMI] Type  • Win32_printer   • Win32_product   • SystemRestore

WMI Disk   • DNS   • PowerShell -Filter   • Windows PowerShell   • Memory

Please email me if you have a script examples. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.

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.

 *


Custom Search

Guy Recommends: WMI Monitor and It's Free!Solarwinds WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.

Fortunately, Solarwinds have created the Free WMI Monitor so that you can actually see and understand these gems of performance information.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

 

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

Please report a broken link, or an error.