Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Method while setting DNS Suffixes???

Status
Not open for further replies.
Oct 10, 2003
90
US
Hey guys, its been a few years since I've been around, but I am trying another round of teaching myself more about scripting. So, here goes.....

The following script works with the exception of the line that says

objNetAdapter.SetDNSSuffixSearchOrder(arrDNSSuffixes)

The error being returned is invalid method. I am looking at the TechNet listing for the method and I am pretty sure I am using the proper procedures in using it.

So, can you see what I'm not doing correctly???

Thank you,

Desktoprat

p.s. the values in the arrays have been changed to ensure I don't get any potential nasty notes from other people in my organization, whoever they may be.




'=========================================================
Option Explicit

Dim strComputer, strPrimaryServer, strSecondaryServer
Dim objWMIService, colNetAdapters, objNetAdapter
Dim errEnable, arrDNSServers, arrDNSSuffixes

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
arrDNSServers = Array("1.2.3.4","1.2.3.5","1.2.3.6","1.2.3.7","1.2.3.8")
objNetAdapter.SetDNSServerSearchOrder(arrDNSServers)
arrDNSSuffixes = Array("abc.net", "abc.edu")
objNetAdapter.SetDNSSuffixSearchOrder(arrDNSSuffixes)
strPrimaryServer = "1.2.3.4"
strSecondaryServer = "1.2.3.5"
objNetAdapter.SetWINSServer strPrimaryServer, strSecondaryServer
Next

MsgBox "NIC has been configured
 
Ok, upon further review and finding a script I had played with some years ago, I added this line in

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
arrDNSSuffixes = Array("abc.net", "abc.edu")
objNetworkSettings.SetDNSSuffixSearchOrder(arrDNSSuffixes)

Script is now working as expected. Feel free to critique or explain why it didn't work in the inititial iteration......

Thanks,

Desktoprat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top