views:

135

answers:

1

Is there any API in Microsoft DNS Server 2008 to add new forward DNS using VBScript or PowerShell or P/Invoke or WMI? It's easy to generate plain text file and put it into \system32\dns.

How to replace a number manual commands in MMC with just a script execution?

+1  A: 
#xyz is dns servername

$A = [wmiclass]"\\xyz\root\MicrosoftDNS:MicrosoftDNS_AType"

$DNSServer = "xyz.R-test.com"
$Zone = "R-Test.com"
$class = 1
$TTL = 3600

#This is your web server IP Address
$IPAddress = "192.168.1.88"

$Sites = Get-content WebSites.txt

Foreach ($Site in $Sites)
{
$A.CreateInstanceFromPropertyData($DNSserver, $zone, $Site, $class, $ttl, $IPAddress)
}

The WebSites.txt is something look like this:
whatever1.R-test.comwhatever2.R-test.comwhatever3.R-test.com

whatever4.R-test.com

…

http://www.highorbit.co.uk/?p=636

http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!994.entry

http://myitforum.com/cs2/blogs/yli628/archive/2008/06/19/powershell-script-to-add-multiple-a-records-in-dns.aspx

FractalizeR

related questions