Page 1 of 1 1
Topic Options
#170856 - 2006-11-30 08:30 PM Change DNS suffix search order
jadewith Offline
Fresh Scripter

Registered: 2003-06-13
Posts: 45
Loc: Good ole U S of A
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


Edited by jadewith (2006-11-30 08:33 PM)

Top
#170861 - 2006-11-30 11:36 PM Re: Change DNS suffix search order [Re: jadewith]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
See SetIPOptions()
Top
#170863 - 2006-12-01 12:10 AM Re: Change DNS suffix search order [Re: Allen]
jadewith Offline
Fresh Scripter

Registered: 2003-06-13
Posts: 45
Loc: Good ole U S of A
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?

Top
#170865 - 2006-12-01 12:44 AM Re: Change DNS suffix search order [Re: jadewith]
Skip Offline
Fresh Scripter

Registered: 2005-07-01
Posts: 41
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
_________________________
-sphilip

Top
#170868 - 2006-12-01 01:10 AM Re: Change DNS suffix search order [Re: Skip]
jadewith Offline
Fresh Scripter

Registered: 2003-06-13
Posts: 45
Loc: Good ole U S of A
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.


Edited by jadewith (2006-12-01 01:12 AM)

Top
#170873 - 2006-12-01 02:46 AM Re: Change DNS suffix search order [Re: jadewith]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
My apologies... yes you are right, SetIPOptions will not work for that.
Top
#170874 - 2006-12-01 04:33 AM Re: Change DNS suffix search order [Re: Allen]
jadewith Offline
Fresh Scripter

Registered: 2003-06-13
Posts: 45
Loc: Good ole U S of A
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

Top
#170879 - 2006-12-01 06:15 AM Re: Change DNS suffix search order [Re: jadewith]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
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.


Edited by Allen (2006-12-01 06:38 AM)

Top
#170961 - 2006-12-04 06:03 AM Re: Change DNS suffix search order [Re: jadewith]
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
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 ?

Top
#170965 - 2006-12-04 08:19 AM Re: Change DNS suffix search order [Re: Chris S.]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Do I see another update coming for Al's UDF
Top
#171036 - 2006-12-05 04:13 AM Re: Change DNS suffix search order [Re: NTDOC]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
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.
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.063 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org