BRONZE PARTNER:
BRONZE PARTNER:
Industry News:

| |
| |
 |
 |
 |
 |
 |
| PowerShell script to add multiple A records in DNS |
 |
|
|
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
|
 |
 |
 |
|
|