Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows PowerShell print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
PowerShell script to add multiple A records in DNS


Bookmark and Share

By: Ying Li
Posted On: 6/20/2008

This article was Previously posted on Ying Li's Blog


Lately our team has received a lot requests to add new DNS records for testing our web server. I was getting tired of add a record in DNS manually for those Host headers in IIS. Here is what I come up with.

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

$DNSServer = "xyz.R-test.com"
$Zone = "R-Test.com"
$class = 1
$TTL = 3600
$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.com

whatever2.R-test.com

whatever3.R-test.com

whatever4.R-test.com

...

If whateverx already has a DNS A record, you will get something like this:


Exception calling "CreateInstanceFromPropertyData" : "Generic failure "
At C:\Documents and Settings\Administrator.RELATED-TEST\My Documents\AddDNSARecords.ps1:13 cha
+ $A.CreateInstanceFromPropertyData( <<<< $DNSserver, $zone,$Site, $class, $ttl, $IPAddress)



Thanks Richard Siddaway for his post Here

  myITforum.com ©2010 | Legal | Privacy