|
|
|||||||
Hello everyone, I am trying to Change DNS Suffix search order to accomodate our new(meaning very first) DNS name spaces. I found a VB script that does what I need but would like to convert it to KiXtart and have had no luck. Code: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration") $strHostName = "" arrDNSSuffixes = Array("crappy.com,silly.net") objNetworkSettings.EnableDNS strHostName, , , arrDNSSuffixes I have figurred out this part from poking around the board, but haven't been able to pull the trigger. Code: $strComputer = "." $objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=-1") strHostName = "" For each $objNetworkSettings in $colItems $dnssuffix=$objNetworkSettings.DNSDomainSuffixSearchOrder("crappy.com,silly.net") Next Thanks for any help |
||||||||
|
|
|||||||
See SetIPOptions() |
||||||||
|
|
|||||||
Hi Allen, I've looked at your udf and it doesn't have a Dns Suffix Search order setting. I tried adding it myself: Code: case $setting="DNSSearchSuffixes" $settings[0]='SetDNSDomainSuffixSearchOrder($value)' but even if it didn't give me the error "expected ')' Line 153", it would only be good for one domain right? and I've got at least 3 to enter. Is SetDNSDomainSuffixSearchOrder even a valid wmi command? |
||||||||
|
|
|||||||
Here is what we had to use for a while. We had this script called from within another script and it worked pretty well Code: SetConsole ("ALWAYSONTOP") If @PRODUCTTYPE = "Windows XP Professional" or @PRODUCTTYPE="Windows 2000 Professional" Else RETURN EndIf $SearchValue = ReadValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters","SearchList") If $SearchValue = "domain1.corp.com,domain2.corp.com,corp.com" RETURN EndIf $SEARCHLIST="HKLM\System\CurrentControlSet\Services\Tcpip\Parameters\" WriteValue($SEARCHLIST, "Searchlist", "domain1.corp.com,domain2.corp.com,corp.com", "REG_SZ") RETURN |
||||||||
|
|
|||||||
Thanks Skip, I found something similar earlier today, and it wrote the entry just fine, only the card wouldn't use the suffixes listed. Yours works fine though, so go figure. I would prefer to make the change via wmi but beggers can't be choosers. I think the reason that the wmi command wasn't working (other than that I'm only a mediocre script writer) comes from microsmurf: DNSDomainSuffixSearchOrder String Space-delimited list of DNS domain suffixes to be appended to the end of host names during name resolution. When attempting to resolve a fully-qualified domain name (FQDN) from a host only name, the system will first append the local domain name. If this is not successful, the system will use the domain suffix list to create additional FQDNs in the order listed and query DNS servers for each Example: "samples.microsoft.com example.microsoft.com" And I don't know how to set a "space delimited" array. |
||||||||
|
|
|||||||
My apologies... yes you are right, SetIPOptions will not work for that. |
||||||||
|
|
|||||||
Does this mean that setting the DNSDomainSuffixSearchOrder cannot be done through WMI with KiXtart? If so "THANK GOD!", that means I'm not as bad as I thought (of course I'm back to even because I didn't know that when I started). If anyone has any idea how to do this through WMI I'd love to hear it, otherwise thank you all for your help. Jason |
||||||||
|
|
|||||||
At least for win32_networkadapterconfiguration DNSDomainSuffixSearchOrder is readonly. http://msdn.microsoft.com/library/defaul...nfiguration.asp Quote: DNSDomainSuffixSearchOrder Data type: string array Access type: Read-only Array of DNS domain suffixes to be appended to the end of host names during name resolution. When attempting to resolve a fully-qualified domain name (FQDN) from a host only name, the system will first append the local domain name. If this is not successful, the system will use the domain suffix list to create additional FQDNs in the order listed and query DNS servers for each. Example: "samples.microsoft.com example.microsoft.com" SetDNSDomainSuffixSearchOrder seems to be NT only. http://msdn.microsoft.com/library/defaul...nfiguration.asp As for your example code, I think (and I would appreciate our COM Gurus to speak up) this is one of those settings that kixtart does not properly handle. There may be another way, but at least you have the reg hack. |
||||||||
|
|
|||||||
This seemed to work for me... Code: $strComputer = "." $objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $strComputer + "\root\cimv2") $objNetworkSettings = $objWMIService.Get("Win32_NetworkAdapterConfiguration") $strHostName = "" $arrDNSSuffixes = Split("crappy.com,silly.net",",") $rc = $objNetworkSettings.EnableDNS($strHostName, , , $arrDNSSuffixes) @SERROR ? |
||||||||
|
|
|||||||
Do I see another update coming for Al's UDF |
||||||||
|
|
|||||||
Well, I considered it. Problem is, SetIPOptions is sort of designed to target specific adapters, where as this DNSServerSuffixOrder thingy applies to all adapters. I need to play with it more, and see if I can incorporate it without causing an issues. |