Set DNS Search Order Server

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Set DNS Search Order & Server

Setzt die DNS Einträge in "Preferred DNS Server", "Alternate DNS Server" und in der "DNS search order" unter den Advanced settings.

 

Visual Basic Code:
'******************************************************************** '* '* File: SetDNSSearchOrder.vbs '* Author: Frank '* Created: 18.02.2010 '* Version: 1.00 '* Modified: 00.00.0000 '* '* Description: Setzt die DNS Einträge neu. '* '* needed: '* '* '* '********************************************************************--> Option Explicit On Error Resume Next Dim strComputer, strDNSServerNew, objWMIService, colNicConfigs, objNicConfig Dim strDNSServerSearchOrder, strIndex, errDNS     '*** configuration ************************************************** strDNSServerNew = "169.254.0.2,169.254.0.3,169.254.0.4,169.254.0.5"   '******************************************************************** If WScript.Arguments.Count < 1 Then WScript.Quit strComputer = WScript.Arguments.Item(0) WScript.Echo "Computer;AdapterIndex;DNS Server Search Order;ReturnCode" Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2") Set colNicConfigs = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") For Each objNicConfig In colNicConfigs strDNSServerSearchOrder = "" strIndex = objNicConfig.Index errDNS = 0 If Not IsNull(objNicConfig.DNSServerSearchOrder) Then strDNSServerSearchOrder = Join(objNicConfig.DNSServerSearchOrder, ",") errDNS = objNicConfig.SetDNSServerSearchOrder(Split(strDNSServerNew, ",")) WScript.Echo strComputer &amp; ";" &amp; strIndex &amp; ";" &amp; strDNSServerSearchOrder &amp; ";" &amp; ReturnCode(errDNS) End If Next     Function ReturnCode(Code) Select Case Code Case 0 ReturnCode = "Successful completion. No reboot is required." Case 1 ReturnCode = "Successful completion. Reboot is required." Case 64 ReturnCode = "Method not supported on this platform." Case 65 ReturnCode = "Unknown failure." Case 66 ReturnCode = "Invalid subnet mask." Case 67 ReturnCode = "An error occurred while processing an instance that is returned." Case 68 ReturnCode = "Invalid input parameter." Case 69 ReturnCode = "More than five gateways specified." Case 70 ReturnCode = "Invalid IP address." Case 71 ReturnCode = "Invalid gateway IP address." Case 72 ReturnCode = "An error occurred while accessing the registry for the requested information." Case 73 ReturnCode = "Invalid domain name." Case 74 ReturnCode = "Invalid host name." Case 75 ReturnCode = "No primary or secondary WINS server defined." Case 76 ReturnCode = "Invalid file." Case 77 ReturnCode = "Invalid system path." Case 78 ReturnCode = "File copy failed." Case 79 ReturnCode = "Invalid security parameter." Case 80 ReturnCode = "Unable to configure TCP/IP service." Case 81 ReturnCode = "Unable to configure DHCP service." Case 82 ReturnCode = "Unable to renew DHCP lease." Case 83 ReturnCode = "Unable to release DHCP lease." Case 84 ReturnCode = "IP not enabled on adapter." Case 85 ReturnCode = "IPX not enabled on adapter." Case 86 ReturnCode = "Frame or network number bounds error." Case 87 ReturnCode = "Invalid frame type." Case 88 ReturnCode = "Invalid network number." Case 89 ReturnCode = "Duplicate network number." Case 90 ReturnCode = "Parameter out of bounds." Case 91 ReturnCode = "Access denied." Case 92 ReturnCode = "Out of memory." Case 93 ReturnCode = "Already exists." Case 94 ReturnCode = "Path, file, or object not found." Case 95 ReturnCode = "Unable to notify service." Case 96 ReturnCode = "Unable to notify DNS service." Case 97 ReturnCode = "Interface not configurable." Case 98 ReturnCode = "Not all DHCP leases can be released or renewed." Case 100 ReturnCode = "DHCP not enabled on adapter." End Select End Function