How to use CreateZone in PowerShell to add DNS zones?

Posted on 2009-05-01
Last Modified: 2012-05-06
I'm trying to create a simple PowerShell script for a Windows Server 2008 Standard to add DNS entries. I am running the script on the local server running DNS. But I keep getting a "Generic failure" error on the CreateZone:

PS C:\Users\Administrator> $dnsserver=[wmiclass]"\\.\ROOT\Microsoftdns:Microsoftdns_zone"
PS C:\Users\Administrator> $dnsserver.createzone("",0,$False,"")
Exception calling "CreateZone" : "Generic failure "
At line:1 char:22
+ $dnsserver.CreateZone( <<<< "",0,$False,"")

I suspect the problem is with the definition of $dnsServer. Rather than using "\\.\" I have used the domain name "\\DC1\" as well as the fully qualified domain name (e.g., DC1.mybigdomain.local) but the same error occurs.  Any thoughts?

CreateZone Method Reference:



Open in new window

Question by:lesterw2
    LVL 17

    Assisted Solution

    Are you running the script as a user that has access to create in DNS?

    Also are you aware that you have a period (.) after your domain? I havent used this command before but its worth a shot!
    change to

    Open in new window

    LVL 1

    Accepted Solution

    I've tried it both with and without a period. Many examples I saw included the period (which is technically correct from what I understand). Thanks for the thought though.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
    Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now