Thursday, December 2, 2010

Recreation DNS Host from the export file in a Microsoft DNS server

The following script is designed to add hosts, a list of exported and host IP addresses that originated from outside the area of a DNS server, Microsoft DNS server DNS particular area.

The basic functions of the script:
AddDNSHost.vbs CScript / DNS Server: DNS Server / DNSZone: DNSZone / hostname: Hostname / hostip: hostip

It's an example:
AddDNSHost.vbs / DNS Server: 192.168.0.1 / DNSZone: DNSZone.local / hostname: this computer/ Hostip: 192.168.1.123

A very simple way to build more commands can be accessed from any application spreadsheet where column A contains the list of host names, column B, to keep their IP addresses respected and column C, the following command ( line 1):

= "AddDNSHost.vbs / DNS Server: 192.168.0.1 / DNSZone: DNSZone.local / hostname:" & A1 & "/ hostip:" & B1

The above command can be copied only once for each row. The resulting command is constructedimmediately be pasted into a command prompt

'* * * * * * * * * * * Start of AddDNSHost.vbs * * * * * * * * * * *

On Error Resume Next

strDNSServer Wscript.Arguments.Named = ("DNS Server")
strDNSZone Wscript.Arguments.Named = ("DNSZone)
strHostName Wscript.Arguments.Named = ("host")
strHostIP Wscript.Arguments.Named = ("hostip)

If Len (Trim (strDNSServer))> 0 and Len (Trim (strDNSZone))> 0 and Len (Trim (strHostName))> 0 and Len (Trim (strHostIP))>0 Then
If Right (UCase (strHostName), Len (strDNSZone) + 1) "." & UCase (strDNSZone) Then
strHostName strHostName = & "." & StrDNSZone
End If
intRecordClass = 1
intTTL = 600

strComputer = "."
September objWMIService = GetObject ("winmgmts: {impersonationLevel = impersonate}" & strComputer & "rootMicrosoftDNS)
September objWMIService.Get objItem = (MicrosoftDNS_AType)
intReturn objItem.CreateInstanceFromPropertyData = (strDNSServer, strDNSZone,strHostName, intRecordClass, intTTL, strHostIP)
If Err.Number = 0 and = 0 Then intReturn
StrHostName & WScript.Echo vbTab & "Added"
Other
StrHostName & WScript.Echo vbTab & "Failed"
End If
End If

'* * * * * * * * * * * Start of AddDNSHost.vbs * * * * * * * * * * *

Visit : Intel Core i7 920 2.66GHz Store

No comments:

Post a Comment