Настройка DNS на хосте

Option Explicit
Dim target
Dim oWMIService
Dim colNetAdapters
Dim oNetAdapter
Dim DNSDomainErr
Dim DNSsearchErr
Dim DNSServer

Target = "."
DNSserver=Array("128.1.2.1", "129.1.2.2")
Set oWMIService = GetObject("winmgmts:\\" & target & "\root\cimv2")
Set colNetAdapters = oWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each oNetAdapter In colNetAdapters
    DNSDomainErr = oNetAdapter.SetDNSDomain("NWTraders.com")
    DNSsearchErr=oNetAdapter.SetDNSServerSearchOrder(DNSserver) 
    WScript.Echo "DNSDomain returned " & (DNSDomainErr)
	WScript.Echo "DNSsearchOrder returned " & (DNSsearchErr)
Next

или

Option Explicit
'On Error Resume Next

dim qQuery
dim oConnection
dim oCommand
dim oRecordSet
Dim oDom
Dim oProvider
Dim oOU
Dim target
Dim oWMIService
Dim colNetAdapters
Dim oNetAdapter
Dim DNSDomainErr
Dim DNSsearchErr
Dim DNSServer

oProvider = "'LDAP://"
oDom = "dc=nwtraders, dc=msft'" 
oOU = "ou=workstations,"
qQuery = "Select Name from " & oProvider _
& oOU & oDom & "where objectClass='computer'"

Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConnection.Open "Provider=ADsDSOObject;"
oCommand.ActiveConnection = oConnection
oCommand.CommandText = qQuery
Set oRecordSet = oCommand.Execute

While Not oRecordSet.EOF
    Target= oRecordSet.Fields("name")
    DNSserver=Array("128.1.2.1", "129.1.2.2")
Set oWMIService = GetObject("winmgmts:\\" & target & "\root\cimv2")
Set colNetAdapters = oWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each oNetAdapter In colNetAdapters
    DNSDomainErr = oNetAdapter.SetDNSDomain("NWTraders.com")
    DNSsearchErr=oNetAdapter.SetDNSServerSearchOrder(DNSserver) 
    WScript.Echo "DNSDomain returned " & (DNSDomainErr)
	WScript.Echo "DNSsearchOrder returned " & (DNSsearchErr)
Next
    oRecordSet.MoveNext
Wend

oConnection.Close
Интересное на сайте: 
0
Голосов пока нет

Оставить комментарий