Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,542 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,819 people online right now. Registration is fast and FREE... Join Now!




Windows DNS scripting

 
Reply to this topicStart new topic

Windows DNS scripting, Modify TTL default value

geotek
18 Aug, 2008 - 01:29 PM
Post #1

New D.I.C Head
*

Joined: 18 Aug, 2008
Posts: 2

I have a large number of domains that I need to update the default TTL value for, but I have not found the exact contructs to make the code work. Here is a rough version of some code I generally use for other tasks. Hopefully, someone can point me in the write direction.

CODE

' This code will hopefully modify the default TTL for a DNS zone.

' Default TTL constrants
const MODIFY_DEFAULT_TTL = <0:0:0:30>

' Option Explicit
Dim objExcel
Dim objSpread
Dim intRow
Dim strSheet
Dim strZone

' File containing all zones to be updated.
strSheet = "C:\Book1.xls"

' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
intRow = 2

' Do Loop
Do Until objExcel.Cells(intRow,1).Value = ""

strZone = Trim(objExcel.Cells(intRow, 1).Value)
strServer = "<serverName>"  ' e.g. ns1.corp.com
intTTL = MODIFY_DEFAULT_TTL

set objDNS = GetObject("winMgmts:\\" & strServer & "\root\MicrosoftDNS")
set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""")
set objDNSZone = objDNS.Get("MicrosoftDNS_Zone.ContainerName=""" & _
                          strZone & """,DnsServerName=""" & _
                          objDNSServer.Name & """,Name=""" & strZone & """")
              strNull = objDNSZone.TTL(intTTL)
objDNSZone.Put_

intRow = intRow + 1
Loop
objExcel.Quit

'End loop
WScript.Echo "Default TTL'S updated"



Thanks
George
User is offlineProfile CardPM
+Quote Post

DeCompile
RE: Windows DNS Scripting
19 Aug, 2008 - 04:19 AM
Post #2

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
Well, I don't really want to point out the obvious.

But why are you changing the TTL of your DNS for ?

Are you not updating it dynamically? Or are you actually running a mainstay DNS server?
User is offlineProfile CardPM
+Quote Post

geotek
RE: Windows DNS Scripting
19 Aug, 2008 - 04:53 AM
Post #3

New D.I.C Head
*

Joined: 18 Aug, 2008
Posts: 2

QUOTE(DeCompile @ 19 Aug, 2008 - 05:19 AM) *

Well, I don't really want to point out the obvious.

But why are you changing the TTL of your DNS for ?

Are you not updating it dynamically? Or are you actually running a mainstay DNS server?


I am lowering the TTL to migrate websites to a different subnet. Do you have any suggestions regarding my code?

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 10:37PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month